in reply to Sort a 2D array based on 2 columns
Please note the following two things:use strict; use warnings; my @megaMotif = ( [ "AGCT", "0", "370", "1" ], [ "AGGT", "3", "52", "1" ], [ "TGAA", "2", "233", "0" ], [ "AGAG", "0", "32", "0" ] ); my @megaMotifSorted = sort { $a->[1] <=> $b->[1] || $a->[3] <=> $b->[3] } @megaMotif;
Did you just change the brackets in your posting or am I going mad? I could have sworn I just copied-and-pasted your code in my editor and the outernmost brackets were square and not round. If you did change them afterwards, make a little note of it otherwise it gets difficult to follow the discussion.
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sort a 2D array based on 2 columns
by masala_curry (Novice) on Apr 26, 2009 at 08:01 UTC | |
by ELISHEVA (Prior) on Apr 26, 2009 at 13:14 UTC |