sri1230 has asked for the wisdom of the Perl Monks concerning the following question:
Got a hash like this
$hash = { k1 => [a1, b1, c1, d1], k2 => [a2, b2, c2, d1], k3 => [a3, b3, c3, d3] k4 => [a4, b4, c4, d3] } For the arrays where the d's are equal i want to do a numerical compar +ision on the a's and add a priority number at the end The output i expect $hash = { k1 => [a1, b1, c1, d1, 1], k2 => [a2, b2, c2, d1, 2], k3 => [a3, b3, c3, d3, 2] k4 => [a4, b4, c4, d3, 1] }
#basically for k1 and k2 the d's are equal and a1>a2 so i added 1 and 2 respectively at the end and a4>a3 etc. I have a solution but wanted to know if anyone had a easier solution for this.(like a one or 2 liner) Thanks in advance.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash of Array Sort question
by ikegami (Patriarch) on Mar 18, 2010 at 15:27 UTC | |
by sri1230 (Novice) on Mar 18, 2010 at 16:37 UTC | |
by ikegami (Patriarch) on Mar 18, 2010 at 19:13 UTC | |
|
Re: Hash of Array Sort question
by Anonymous Monk on Mar 18, 2010 at 14:24 UTC | |
by sri1230 (Novice) on Mar 18, 2010 at 15:08 UTC | |
by ikegami (Patriarch) on Mar 18, 2010 at 15:38 UTC |