Schwartzian Transformによるソート例 例題 $, = ' '; @data = qw(A10 F4 F16 X29 F18 F15 B29 C130); @ret = map { $_->[0] } sort { $a->[1] cmp $b->[1] || $a->[2] <=> $b->[2] } map { [$_, split(/(\d+)/, $_)] } @data; print "Unsorted: ", @data, "\n"; print "Normal sort: ", sort(@data), "\n"; print "My sort: ", @ret, "\n"; 実行結果 Unsorted: A10 F4 F16 X29 F18 F15 B29 C130 Normal sort: A10 B29 C130 F15 F16 F18 F4 X29 My sort: A10 B29 C130 F4 F15 F16 F18 X29