in reply to Sorting strings
Since I haven't done a version of my standard "natural sort" trick that handles negative numbers recently, here goes:
- tye (but my friends call me "Tye")my @deltas= qw( -6h0m +11h39m 0h2m +1h7m -12h8m ); @deltas= @deltas[ do { s#([-+]?\d+)# "\x80" ^ pack"N",$1 #ge for my @sort= @deltas; sort { $sort[$a] cmp $sort[$b] } 0..$#sort; } ]; print "@deltas\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (tye)Re: Sorting strings ("natural sort" w/ negatives)
by Hofmator (Curate) on Aug 31, 2001 at 21:33 UTC | |
by tye (Sage) on Aug 31, 2001 at 22:49 UTC |