http://www.perlmonks.org?node_id=109051


in reply to Sorting strings

you can use the clever form of sort:
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)); }
UPDATE: fixed typos & sub error (thanks Hofmator)