Your "new" sort order is not unique, or I don't understand the criteria used to sort. I think I can find two possible orders for your example:
1245 0000 1246 1247 1248
1245 1246 1247 1248 0000
Why is the second order not allowed? Is it because the 0000 was to the left of the 1246 ? If such is the case, I would make the elements so that they order "properly" by encoding them differently:
- Translate all elements by appending the "normal" marker. Let's define the "normal" marker as "n".
- For every element 0000n (a "normal 0"), replace that element by the element to the right of it, but omit the normal marker. In your example, the 0000n would become 1246.
- Let the normal Perl sort rip through your items.
- Convert all your items back to their old format.
Depending on your actual needs (for example, times wrapping around the day border), it might be more convenient to first convert all your "numbers" into seconds since the 1. January 1970, and then sort the times.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.