|
|
| P is for Practical | |
| PerlMonks |
Re^2: sorting the column of array elementby sauoq (Abbot) |
| on May 24, 2012 at 11:45 UTC ( #972225=note: print w/ replies, xml ) | Need Help?? |
|
Assuming, like you said, an array of arrayrefs—which is a good assumption, I think—this code would try to order the array refs in @array by the first elements contained in the arrays they reference. That seems very unlikely to be what he wants. Update: If he wants to sort the array referenced by $array[0], the code I gave will work. If he wants to sort all of his "columns," he should sort the indexes based on his sorting column using something like: And then use the array of sorted indexes to map the sorted order onto the actual columns with something like this:
It's up to him to be sure the "columns" are the same length, of course.
-sauoq "My two cents aren't worth a dime.";
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||