xesecre has asked for the wisdom of the Perl Monks concerning the following question:
I have a question for the Wise Perl Monks, thanks in advance. I am using map and sort to sort by 2 columns. The trouble I am having is, it does sort the first column but it will not sort by any other column when I change the number. The list has numbers to sort. This is delimited by tab. What am I doing wrong?
my @sorted = map {$_->[0]} sort { $a->[0] <=> $b->[0] || sort { $a->[1] <=> $b->[1] } map {chomp;[$_,split(/\t/)]} <FILE>; print OUT "$_\n" for @sorted;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl sort
by Corion (Patriarch) on Apr 26, 2016 at 14:30 UTC | |
|
Re: Perl sort
by Laurent_R (Canon) on Apr 26, 2016 at 20:28 UTC |