Re: Multidimensional Array

2012-12-04 Thread Alan Forrester
On Wed, Nov 28, 2012 at 2:15 PM, John M. wrote: > Hi , > > Currently I am using Ruby and a beginner > > I have the following multidimensional Array: > > [[value1, value1_other1 ,value1_other2], [value2, > value2_other1,value2_other2], [value3, value3_other1,value3_other2]] > > but i would like to

Re: sorting data from a file

2012-12-04 Thread Alan Forrester
On Wed, Nov 28, 2012 at 2:47 PM, Ismail M. wrote: > I haven't done any thing yet.. i just didn't know where to start. > btw those numbers are not arrays. its the content of the file. Documentation for Ruby is here http://www.ruby-doc.org/core-1.9.3/ You're going to need to look at things like "

Re: sorting data from a file

2012-12-04 Thread Alan Forrester
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 ap

Re: sorting data from a file

2012-12-04 Thread Alan Forrester
On 28 Nov 2012, at 19:15, 7stud -- wrote: > Alan Forrester wrote in post #1086915: >> >> In your script, read the file into an array using >> myarray = IO.readlines("myfile.txt") >> > > Why would you suggest that? What's the matter with the method: > > IO.foreach(fname) {|line| #code here}