On Wed, Nov 28, 2012 at 3:36 PM, Ismail M. <[email protected]> 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
-- You received this message because you are subscribed to the Google Groups
ruby-talk-google group. To post to this group, send email to
[email protected]. To unsubscribe from this group, send email
to [email protected]. For more options, visit this
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en