Sort months ( with strings ) algorithm

Posted by Oscar Reyes on Stack Overflow See other posts from Stack Overflow or by Oscar Reyes
Published on 2010-01-20T00:02:11Z Indexed on 2010/04/19 12:23 UTC
Read the original article Hit count: 252

I have this months array:

["January", "March", "December" , "October" ]

And I want to have it sorted like this:

["January", "March", "October", "December" ] 

I'm currently thinking in a "if/else" horrible cascade but I wonder if there is some other way to do this.

The bad part is that I need to do this only with "string" ( that is, without using Date object or anything like that )

What would be a good approach?

© Stack Overflow or respective owner

Related posts about language-agnostic

Related posts about array-sorting