Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: how to sort this?

by saintmike (Vicar)
on Mar 25, 2006 at 05:48 UTC ( #539147=note: print w/replies, xml ) Need Help??

in reply to how to sort this?

What do you want to sort it by? Sort it like strings? Like numbers? By extracted integers? Or a combination of all of the above?

Helps to know the requirements before starting an implementation.

Replies are listed 'Best First'.
Re^2: how to sort this?
by sen (Hermit) on Mar 25, 2006 at 05:57 UTC

    hi saint,

    my requirement is to sort by integers. also i need the output as

    @a = (1x1 1x1 1x2 1x12 2x1 4x0 4x1 4x12 10x1 12x1 12x3 22x3);


      Hi sen try this it gives your exact output,

      #!/usr/local/bin/perl @a1 = qw/1x1 1x12 12x3 10x1 4x12 4x1 1x1 22x3 2x1 4x0 12x1 1x2/; @out = sort { (split 'x', $a, 2)[0] <=> (split 'x', $b, 2)[0] } sort { (split 'x', $a, 2)[1] <=> (split 'x', $b, 2)[1] }@a1; print "@out";

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://539147]
[stevieb]: I'm checking some other versions. This is a little frightening
[pryrt]: Sorry, my bad: it was't done downloading when I did the sha1sum... now I match your 309ad... value
[stevieb]: I'll see how to get in touch with someone and advise that there's an issue. Thanks for helping me confiirm pryrt!

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2017-03-29 21:02 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (353 votes). Check out past polls.