in reply to sort by a multiple columns
It's a GRT (kinda, probably not the best performance, though). The trick with the end marker is especially ugly, but without it the output would be wrong.#!perl use strict; use warnings; my @un_sorted = ( [3, 4, 23, 4, 5], [3, 4, 56, 2, 4], [2, 3, 43, 5, 3], [2, 3, 43, 6], [3, 4] ); my $end = chr(1e6); print join "\n", map { join ',', @$_ } map { splice @$_, $#_; $_ } map { [(map(ord, split('', $_)))]} sort map { join('', map chr, @$_) . $end } @un_sorted;
|
|---|