From: "Jesús Gabriel y Galán" Date: 2010-11-30T19:16:58+09:00 Subject: Re: Help sorting an array On Tue, Nov 30, 2010 at 10:24 AM, Jim Burgess wrote: > Hi, > > First of all, thank you very much for the replies. > In the mean time I have managed to hack together a small function to do > what I want, but it is too embarrassingly bad to post here and I used > one of the other proposed solutions instead. > > I agree that a different data structure would be much less cumbersome, > but I wouldn't know which. What I'm doing is parsing a html document (a > calendar) into an array, and using that array to create widgets in a > FXRuby GUI. The month names serve as the title of a label and out of the > Event objects I then create the appropriate text fields, labels and > group boxes for each event. As a month can have multiple events I found > it easier to do it this way, as otherwise I would have to find some way > of ordering events to month names, which at first glance seemed pretty > complicated. > > If anyone has any suggestions of a better way to approach this problem, > I would be very glad to hear them. > > Thanks for your help so far. I agree with both Robert and Daniel. I would make the month a field of the Event, so you can query it, order events by month, etc. And then I would also go with Daniel's suggestion of having a hash indexed by month so you can get at the set of events for a month easily when you need it (for example, when the user clicks on Next Month). Jesus.