in reply to substr sort ??

Actually you can just lose the substr. It isn't gaining you anything. Perl will convert the strings to numbers and just Do The Right Thing.

@values = sort { $a <=> $b } @values;

Update: broquaint reminds me that this will generate warnings under "use warnings". It will still give the right answer tho' :)

--
<http://www.dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re2: substr sort ??
by dragonchild (Archbishop) on Aug 22, 2003 at 12:56 UTC
    @values = sort { no warnings; $a <=> $b } @values;

    *shrugs*

    ------
    We are the carpenters and bricklayers of the Information Age.

    The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.