9.5. Multi-Level Sort with the Schwartzian TransformIf we need to sort on more than one criterion, the Schwartzian Transform is still up to the task. my @output_data = map $_->[0], sort { SORT COMPARISON USING $a->[1] AND $b->[1] or ANOTHER USING $a->[2] AND $b->[2] or YET ANOTHER USING $a->[3] AND $b->[3] } map [ $_, SOME FUNCTION OF $_, ANOTHER, YET ANOTHER ], @input_data; This code skeleton has a three-level sort comparison, using three computed values saved in the anonymous array (alongside the original data item to be sorted, which always comes first). |