From: Alan Forrester Date: 2012-11-29T00:50:18+09:00 Subject: Re: sorting data from a file On Wed, Nov 28, 2012 at 3:36 PM, Ismail M. wrote: > of course I see your point Jan E. > > I opened/read the file and displayed in on ruby command promt. > > then i thought of a way to sort the data in the file. > > > l = [1,2,3,3,1,6,5] > > smallest = l.sort.first 4 > > => [1,1,2,3] > > however applying this method in my case is the problem. How do i connect > this method to my file then make a loop than sort each line in my file. Write a script "script.rb" and run it from the command line by typing "ruby script.rb". In your script, read the file into an array using myarray = IO.readlines("myfile.txt") Then you have to think about the elements of the array and look at the documentation to work out the rest. Alan