From: desibtis@... (Sang DeSibtis) Date: 2001-12-30T08:37:30+09:00 Subject: [ruby-talk:29666] Re: How to sort " sort -k3,3 -k9,9 file" desibtis@hotmail.com (Sang DeSibtis) wrote in message news:<6039af6a.0112281013.54931fd4@posting.google.com>... > nobu.nokada@softhome.net wrote in message news:<200112280539.fBS5dio13504@sharui.nakada.kanuma.tochigi.jp>... > > Hi, > > > > At Fri, 28 Dec 2001 14:14:41 +0900, > > desibtis@hotmail.com (Sang DeSibtis) wrote: > > > How do I sort an array of lines having fix number of columns without > > > having to pass in a block of code to the array.sort() methode ? I > > > would like the output to be like the subject line--sort column 3 and > > > column 9. Like, sort -k3,3 -k9,9 filename . > > > > In 1.6: > > array.collect {|s| [s[2], s[8], s]}.sort.collect {|s| s.last} > > I did just like what you suggested and I got two numbers (int) followed by the s (array item) when I used puts to look at the result. Do I have to add any require statement anywhere in the 'rb' file to get it to work correctly? > > In 1.7: > > array.sort_by {|s| [s[2], s[8]]} > > > > Is there an ftp site I can just download it? I don't know how to use that CVS stuff. > > Nobu Nakada > > Nobu, > > Thanks, I try and it doesn't work. I add a bang at the end of > array.collect! but nothing got sorted. I am running Ver.1.6.5 > , does that matter? BTW, I can't locat Ver. 1.7 to try another > command you provided.