in reply to divide by '/'

@numbers = qw( 1/23 3/45 65/0 6/01 0/100 123/4568 ); @sorted = sort { (split('/', $a))[0] <=> (split('/', $b))[0] } @numbers; print "@numbers\n";

Very embarrassing update: That last line should indeed read print "@sorted\n"; Thanks to jynx for the /msg.

Replies are listed 'Best First'.
Re: Re: divide by '/'
by jynx (Priest) on Apr 12, 2001 at 23:19 UTC

    Did you mean:
    print "@sorted\n";
    For that last line?

    jynx

      Yup. Stringifying the array automatically uses $" ($LIST_SEPARATOR if you use English;) as a separator. It's a shortcut for saying   print join($", @sorted), "\n"; which, since $" defaults to ' ', is a also a shortcut for   print join(' ', @sorted), "\n";