From: Robert Klemme Date: 2010-11-30T06:35:24+09:00 Subject: Re: Help sorting an array On 11/29/2010 04:47 PM, Jim Burgess wrote: > Hi, > > I have an array consisting of "Event" objects, and string elements which > contain the names of months. > It looks like this: > [#, #, "MARCH", #, > #, "FEBRUARY", #,"JANUARY"] > > Currently the events precede the months they are ordered to. > > Is there any way to reverse this so that the months precede the > events? > Like this: > ["MARCH", #, #, > "FEBRUARY",#, #, "JANUARY", > #] > > I have been scouring the documentation for ages and have also googled > everything I can think of (e.g. Array#split) to try and find a solution, > but with no luck. > > Can anyone point me in the right direction. > I am grateful for any help. I would chose different data structures: if your events have a month where they are scheduled I would make the month an attribute of Event. Then you can sort your Event instances according to any criteria you like - including month. Mixing types in a collection can make handling that collection quite complex - as you are experiencing. Kind regards robert