my (@array) = ("fred","barney","wilma","betty"); @array = sort @array; @array = reverse @array; print "@array\n";
But if you have to do that with a lot of arrays in one program, you can save on typing by putting it into a sub:
sub reversi { my (@array) = @_; print reverse sort(@array); }
and then just call reversi(@yourarrayhere)
UPDATE: Modified sub code to follow jZed's suggestion. UPDATE: Fixed spelling error pointed out.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Reverse Alphabetically Sorting an array
by merlyn (Sage) on Jan 10, 2005 at 01:02 UTC | |
by matra555 (Monk) on Jan 10, 2005 at 13:09 UTC | |
by Aristotle (Chancellor) on Jan 10, 2005 at 19:34 UTC | |
by mowgli (Friar) on Jan 10, 2005 at 19:15 UTC | |
|
Re: Reverse Alphabetically Sorting an array
by jZed (Prior) on Jan 09, 2005 at 23:24 UTC | |
| |
|
Re: Reverse Alphabetically Sorting an array
by DaWolf (Curate) on Jan 11, 2005 at 05:30 UTC |