in reply to Re^3: Sorting based on any column
in thread Sorting based on any column

Another piece of the puzzle: sort accepts code refs as the sorting function.

my @l = (10, 2, 200, 23, 3, 9, 11, 1); my $num = sub { $a <=> $b }; my $str = sub { $a cmp $b }; print join(", ", sort $num @l ), "\n"; print join(", ", sort $str @l ), "\n"; __END__ 1, 2, 3, 9, 10, 11, 23, 200 1, 10, 11, 2, 200, 23, 3, 9