Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Answer: How do I sort a list in reverse order?

by vroom (Pope)
on Jan 21, 2000 at 00:36 UTC ( #2257=categorized answer: print w/replies, xml ) Need Help??

Q&A > sorting > How do I sort a list in reverse order? - Answer contributed by vroom

Use a sort block and switch the positions of the special variable $a and $b
@sorted=sort{$b cmp $a} @unsorted; # for strings @sorted=sort($b <=> $a) @sorted; # for number
Another option is:
@sorted=reverse sort @unsorted #for strings

Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (14)
As of 2016-10-24 19:31 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (309 votes). Check out past polls.