On Jan 30, Boon Chong Ang said:

>Just say I want to sort the row by using the fifth column data as
>reference from the smallest the largest number

>Abc 12.8 8 "left" 1 1.7
>Dgf  12.3 9 "right" 4 2.6
>bac 12.8 8 "left" 1 3.7
>Def  13.8 9 "top" 0 19.7
>gef  14.8 9 "left" 0 19.7
>etg  12.8 2 "left" 7 34.7
>efg  16.8 5 "right" 0 56.7
>baf  32.8 7 "bottom" 5 79.8
>cef  16.8 4 "right" 0 89.7

I suggest you search the web for "schwartzian transform", because that's
what I'm about to show you:

  my @sorted =
    map $_->[0],                  # get back the original string
    sort { $a->[6] <=> $b->[6] }  # sort on 5th field (0 is the original)
    map [ $_, split ],            # array ref [string, fields]
    @data;

Read it from the bottom up.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to