From: Dan Doel Date: 2003-08-12T06:27:05+09:00 Subject: Re: Ruby and OOP-design (question of an old "procedural person" ;) Meino Christian Cramer wrote: >Hi, :) > > THANK YOU VERY MUCH FOR THE IMMENS RESPONSE TO MY QUESTION! > > I am very happy to be on this very communicative list :o) ! > > Since I am at the very very beginning of Ruby-Programming please > understand, that I only understand the smallest part of the > discussion... > > In the meantime I git a sorted list of "my" shortwave transmitters. > > I did: > > @list.push( [freq, stat, time, days, lang, graf, targ, > loca, powr, azim,rema, stau, modu, na, ca, > sa, eu, af, me, as, au, pa, cira, coco, coun, > long, lati, loco, regi, stn , prst, prog] ) > > for each input line. > > Then I did a > > @list.sort_by { |item| [item[0], item[2] ] } > > and it works smooth and fast as a ligthning. > > The above expressions sorts the broadcasters first on frequency then > on on-air time. > > Then I thought of a list first sorted by time and then by frequency > and wrote > > @list.sort_by { |item| [item[2], item[0] ] } > > and astonishly Ruby quaks ;) with : > > swlist:62:in `sort_by': comparison of Array with Array failed (ArgumentError) > from swlist:62 > > ("swlist" is the name of my ruby-script) > > I dont understand that... > > I am sure that the bug is sitting in front of my monitor...but... > > What is it what I did so badly wrong ? X) > > Thank you very much for any help in advance ! > > Keep being Ruby! > Meino > > > Maybe there's a problem with one of the times? Since the first sort_by would look at item[0] first and only item[2] if both item[0]'s are the same (I think), it might skip over the problem time value, while the second wouldn't be able to; Maybe try printing out all the item[2] values and looking for something fishy there? Just a thought. - Dan