in reply to Helping with sorting
use strict; my @array = qw(2aa 2ba 12kf 9cn 9vn 21sg); my @sorted = sort {$b <=> $a || $b cmp $a } @array; print $_,$/ foreach @sorted;
update: the above does both (letters and numbers) in descending order what I think the OP wanted was descending numbers ascending letters. so the following should work:
my @array = qw(2aa 2ba 12kf 9cn 9vn 21sg); my @sorted = sort {$b <=> $a || $a cmp $b } @array; print $_,$/ foreach @sorted;
-enlil
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Helping with sorting
by pg (Canon) on Apr 02, 2003 at 05:58 UTC | |
|
Re: Re: Helping with sorting
by rinceWind (Monsignor) on Apr 02, 2003 at 12:27 UTC | |
|
Re2: Helping with sorting
by dragonchild (Archbishop) on Apr 02, 2003 at 15:59 UTC |