in reply to How can I sort this data on the first field
my @sorted = map { $_->[1] } # pick interesting data sort { $a->[0] <=> $b->[0] } # sort numerically on first field map { [ split /\|/, $_, 2 ] } # extract sortable field: $_->[0] i +s sortable, # $_->[1] i +s data <DATA>;
This is a simple variant of the Schwartzian Transform. Read it upwards.
In the original transform, the original data is kept around as one of the elements of @$_. Here I was assuming you didn't need to display the sort number — but if you did, then you need to do something slightliy different than a split.
|
---|