Re: Best way to sort arrays




Could you not cut out the first query? Just in your second query lose
the 'limit' clause and then when you print "all entries", use the
$lastentries result. If ordered backwards, start from the last key and
iterate backwards, I suppose.

And then when you print part 2, just take the first 5.

Other than that, I would go with the 3 queries. Is there a need for it
to be much faster?

I agree .... there are ways to work around the problem.

I could do something like:

echo 'Last 5 entries';
for ($i=count($allentries),$i>(count($allentries)-5);$i--)
{
echo $allentries[--$i].'<br />';
}

But It still bothers me that I cant simply extract 5 rows that have largest/smallest value in an array field from a multi dimentional array. Is there really no better way to do this ?

Floortje

.