in reply to Hash sorting with dates and 12 hour time format.
When working on a multi-key sort, it's important to text the items in the right order. In this case, you need to do the comparisons in the following order:
In addition, you will need to deal with the fact that 12:01 AM should sort to less than 1:00 AM. Your months also won't sort nicely ('10' sorting to less than '9').
You could break this string into a series of sub-keys and compare them in order, or pack them up into a fixed-field string that sorts how you want.
Once you've figured out your key, you'll want to apply either the Schwartzian Transform or the Guttman Rosler Transform to the problem.
Update: Added links for the algorithms.
|
---|