Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Sorting Question

by JediWizard (Deacon)
on Oct 04, 2004 at 18:48 UTC ( #396332=note: print w/replies, xml ) Need Help??

in reply to Sorting Question

I don't see any sorting going on in this code. What exactly are you trying to sort? If you are trying to sort @list, try this:

@list = sort({$a cmp $b} @list);
May the Force be with you

Replies are listed 'Best First'.
Re^2: Sorting Question
by Roy Johnson (Monsignor) on Oct 04, 2004 at 18:49 UTC
    Which is just the same as @list = sort @list

    Caution: Contents may have been coded under pressure.
      although you may want to actually sort alphabetically (ie case-insensitive) instead of ASCIIbetically:
      @list = sort { lc $a cmp lc $b } @list;

        Which is why it's often a good idea to use locale when sorting. Then you don't have to contort yourself so much to get good sorting results.

        Damon Allen Davison

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://396332]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (1)
As of 2021-05-09 22:51 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (102 votes). Check out past polls.