I need to order the @list array by insertDate, but how can I access it since it is a $obj array?
I tried Perl's sort function but I don't understand how it works with this kind of array composed of $obj.
sub getLastQuestions {
my ($page) = @_;
$page ||= 1;
my $questionPerPage = 30;
my @list = [];
my @questions = $db->findNodes("/db/questions/question");
if (@questions) {
foreach my $question (@questions) {
my $id = $question->findvalue("\@id");
my $title = $question->findvalue("title");
my $author = $question->findvalue("author");
my $insertDate = $question->findvalue("insertDate");
my $obj = Model::Question->new(
path => "vedi-domanda.cgi?id=" . $id,
title => $title,
author => $author,
insertDate => $insertDate
);
# Aggiungi uno
push @list, $obj;
}
}
return @list;
}
insertDate? And how are you going to access it through$obj?