in reply to Sort problems
my @new_list = map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { /(a|b)(\d+)_(\d+)\[(\d+)\]/ or die "Can't par +se $_"; [$_, sprintf "$1%05d%05d%05d", $2, $3, $4]; } @split_list;
Make a sortable pair for each element of the array. Concatenate first letter with all the numbers in an element. Expand every number to 5 digits with leading zeros. Then sort the pairs alphabetically by second element and take original elements from sorted pairs
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sort problems
by ikegami (Patriarch) on Dec 11, 2008 at 16:01 UTC | |
by erez_ez (Acolyte) on Dec 11, 2008 at 16:19 UTC | |
by ikegami (Patriarch) on Dec 11, 2008 at 17:20 UTC | |
by erez_ez (Acolyte) on Dec 23, 2008 at 13:39 UTC | |
by ikegami (Patriarch) on Dec 23, 2008 at 18:03 UTC | |
| |
|
Re^2: Sort problems
by erez_ez (Acolyte) on Dec 11, 2008 at 15:51 UTC |