in reply to Sort an array using the Schwartzian transform

There's no need for any transform here.
my @sorted = sort {do {no warnings 'numeric'; $a <=> $b}} @unsorted;
will do. (Or some other variation to turn the warning off).

I wish people would stop bending their code backwards just to avoid a warning. Don't be afraid to turn warnings off in such cases.

Replies are listed 'Best First'.
Re^2: Sort an array using the Schwartzian transform
by salva (Canon) on Jan 21, 2011 at 20:35 UTC
    Oops, I though that your code was wrong because
    DB<1> x sort { $a <=> $b } (1_0, 1_00, 2_0 ) 0 10 1 20 2 100
    but actually...
    DB<2> x sort { $a <=> $b } qw(1_0 1_00 2_0) 0 '1_0' 1 '1_00' 2 '2_0'