in reply to Sort based on a delimited field in array elements without affecting original array elements
Take a look at the Schwartzian or Guttman Rosler Transforms, both of which are ideal for this kind of (and more advanced!) sorting ...
@array = map { $_->[0] } # strip meta data sort { $a->[1] <=> $b->[1] } # sort by meta data map { [ $_, /([^!]+)/ ] } # build meta data @array;
You might also want to check out japhy's Resorting to Sorting tute.
Update: Tweaked the example for readability.
--k.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sort based on a delimited field in array elements without affecting original array elements
by tadman (Prior) on Mar 01, 2002 at 23:36 UTC | |
by I0 (Priest) on Mar 01, 2002 at 23:47 UTC |