From e02417808c58c8c840a03072fbd078b7e9df043c Mon Sep 17 00:00:00 2001 From: Romain d'Alverny Date: Mon, 18 Apr 2011 20:49:39 +0000 Subject: better sort function --- index.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'index.php') diff --git a/index.php b/index.php index 1c4eae9..9083a18 100644 --- a/index.php +++ b/index.php @@ -361,9 +361,31 @@ if ($total > 0) { $s .= '

'; $s .= ''; - ksort($buildtime_stats); + + /** + */ + function timesort($a, $b) + { + $a = explode(' ', trim($a)); + $b = explode(' ', trim($b)); + + if ($a[1] == 'hour' || $a[1] == 'hours') + $a[0] *= 3600; + + if ($b[1] == 'hour' || $a[1] == 'hours') + $b[0] *= 3600; + + if ($a[0] > $b[0]) + return 1; + elseif ($a[0] < $b[0]) + return -1; + + return 0; + } + uksort($buildtime_stats, "timesort"); + foreach ($buildtime_stats as $time => $count) { - $s .= sprintf('', + $s .= sprintf('', $time, $count); } // TODO (rda) compute/show average for all builds -- cgit v1.2.1
Build time
%s%d
%s%d