I want to sort the months of the year starting at any month, but January needs to show up after December if January isn't the starting point. Can I do that in an array or do I need a special data structure or algorithm to do that?
Tell me more
×
Programmers Stack Exchange is a question and answer site for
professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.
|
|
you can easily do this with just an array. |
|||
|
|
|
Check this Java-ish code:
|
|||
|
|
|
Many sorters let you provide your own comparator which dictates the sort order. Write one that implements your rules and and supply it to the sort function. |
|||
|
|
