in reply to How can I sort this data on the fourth field?
I'd use merlyn's Schwartzian Transform:
chomp ( my @data = <DATA> ); my @sorted = map { $_->[0] } sort { $a->[1] <=> $b->[1] } map [ $_, (split)[3] ], @data; print "$_\n" for @sorted; __DATA__ 0 TOTAL 11997 26981 0 root 1089 2594 1 daemon 0 0 594 pipmp01 591 1151 958 maestro 335 685
Output:
1 daemon 0 0 958 maestro 335 685 594 pipmp01 591 1151 0 root 1089 2594 0 TOTAL 11997 26981
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How can I sort this data on the fourth field?
by country1 (Acolyte) on Aug 16, 2007 at 12:29 UTC | |
by FunkyMonk (Bishop) on Aug 16, 2007 at 13:54 UTC | |
by country1 (Acolyte) on Aug 16, 2007 at 14:23 UTC | |
by FunkyMonk (Bishop) on Aug 16, 2007 at 14:31 UTC |