PDA

View Full Version : How do I reverse sort?



dorothyc
January 5th, 2001, 01:07
I mean...
how do I make the items with a higher value in the array go to the bottom of the list instead of the top?

Thanks

Koolguy
January 5th, 2001, 01:20
What language are you talking about, php? perl?

dorothyc
January 5th, 2001, 01:22
perl

Grant
January 5th, 2001, 03:45
Originally posted by dorothyc
perl Just use the perl reverse function. @array = reverse @array;

dorothyc
January 5th, 2001, 07:03
thanks

Jerry
January 5th, 2001, 23:27
the proper way to do this is..

@array = sort { $b <=> $a } @array;

that will sort by numbers in descending order.. (higher to lower)