Sort on Pipe-Delimited Column

From: Jeff Westman (westfour_at_yahoo.com)
Date: 05/30/04

  • Next message: John W. Krahn: "Re: Sort on Pipe-Delimited Column"
    Date: Sat, 29 May 2004 19:59:19 -0700 (PDT)
    To: perl_help <beginners@perl.org>
    
    

    Hello,

    I have some data that is pipe-delimited, that I would like to sort
    on the first column (numeric). The data looks like this:

    173|Supertramp|The Very Best of Supertramp
    19|Story, Liz|My Foolish Heart
    54|Tchaikovsky|Nutcracker Suite
    187|Tesla|Time's Makin' Changes: The Best of Tesla

    and once sorted, it should look like

    19|Story, Liz|My Foolish Heart
    54|Tchaikovsky|Nutcracker Suite
    173|Supertramp|The Very Best of Supertramp
    187|Tesla|Time's Makin' Changes: The Best of Tesla

    I tried usint "sort {$a <=> $b}" but got an error:

    Argument "173|Supertramp|The Very Best of Supertramp" isn't numeric
    in sort at med2cdr.pl line 1.

    So I know I have to write my own sort sub-routine, perhaps using
    'split', but I haven't a clue where or how to write that.

    Any help would be greatly appreciated!

    TIA

    Jeff

            
                    
    __________________________________
    Do you Yahoo!?
    Friends. Fun. Try the all-new Yahoo! Messenger.
    http://messenger.yahoo.com/


  • Next message: John W. Krahn: "Re: Sort on Pipe-Delimited Column"

    Relevant Pages

    • Re: change format
      ... the file names are sort of dataL200.txt, ... i can use this for number crunching. ... -- Supertramp (Fool's Overture) ...
      (comp.soft-sys.matlab)
    • Re: [BUG] r200 dri driver deadlocks
      ... Where in the DRM I can proform the needed test and sort. ... Do you Yahoo!? ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: Download
      ... > bookshop with FC attached ... if he can't sort this one out, ... Do You Yahoo!? ... Mail has the best spam protection around ...
      (Fedora)
    • RE: FXP driver....
      ... > it's some sort of timing ... >>To unsubscribe, send any mail to ... Do You Yahoo!? ... Mail has the best spam protection around ...
      (freebsd-questions)
    • Re: Help required with suspicous internet activity
      ... Not that Yahoo is a bunch of Scumware ... but every time I see this sort of thing start up ... that I'm using to spot this garbage is F-secure firewall. ... popular with the Aussies, Russians, Canadians, etc ...
      (alt.computer.security)