Hi all, I am looking for a way to sort times. my problem is that I do not always have a time available.
I have a pre-sorted arrat that looks something like this:
@ar = ( 1245, 1248, 0000, 1246, 1247 );
sort{ $a <=> $b } @ar;
would sort all values, returning ( 0000, 1245, 1246, ... ).
I only wish to move larger numbers to the end, returning
(1245,0000,1246,1247,1248).
Writing a new sort algorithm would solve this, but I was wondering, if there is a way to teach sort to do so, and if this was possibly faster.
Actually by pre-sorted I mean that all larger values simply need to be sorted upwards in the array, so 1248 will be at the end while in the end while the other values are in the right order already.
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.