in reply to Why programming is so much more than writing code
Well, I can't comment on the meaningfullness of the name as you've removed it, but the intent of the code is clear. Even if the formatting is a bit awkward. (operators at the end of the lines? Come on! This ain't Ruby ... you don't have to hint the compiler that we are not done with the statement yet!)
This, in my humble opinion, rather readable snippet of code is supposed to be used by the sort() routine and specifies that the AoA is to be sorted by 3rd, 2nd, 1st, 0th and 4th columns in this order of importance. You might want to use constants instead of the numbers to specify the columns, but that's about the best you can do.
Unless of course you want to factor out the indices and use something like
which would definitely need some explanation. Other than that whenever you see <=> or cmp, especially if comparing (some part of) $a and $b, think "sort".sub SUB_NAME { for (3,2,1,0,4) { # sort by the specified columns my $res = ($a->[$_] <=> $b->[$_]) and return $res; } }
Update: Oops. Good catch merlyn, thanks. A reminder to test the code I post here.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Why programming is so much more than writing code
by merlyn (Sage) on May 07, 2007 at 21:44 UTC | |
|
Re^2: Why programming is so much more than writing code
by GrandFather (Saint) on May 07, 2007 at 21:57 UTC | |
by blazar (Canon) on May 07, 2007 at 22:05 UTC |