in reply to Sorting strings
UPDATE: fixed typos & sub error (thanks Hofmator)my @normalTimes = ('+1h6m', '0h13m', '-4h10m', '-6h5m'); my @sortedTimes = sort { getMinutes($b) <=> getMinutes($a) } @normalTi +mes; sub getMinutes { my($hour,$minute) = split(/[hm]/, shift); return( ($hour * 60) + (($hour > 0) ? $minute : -$minute)); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Sorting strings
by Hofmator (Curate) on Aug 30, 2001 at 16:36 UTC | |
by ChemBoy (Priest) on Aug 30, 2001 at 18:54 UTC |