On Mon, Sep 8, 2008 at 9:37 AM, Robert M. [email protected] wrote:
Say for instance I have an array of dates in string format
dates = [‘06/12/08’, ‘11/11/06’, ‘01/01/07’]
I want to sort this array in ascending order without using Ruby’s
built-in date class. Is there a way of doing this?
Just started Ruby and I’m pretty much a newbie. I tried the sort!, but
it sorts only by day.
Is there any reason you don’t want to use the Date class?
If you want to compare dates alfanumerically you need to have
the year first, then the month and then the day. You could change your
data to be that way and then simple string sorting will work.
Hope this helps,