diff options
author | Romain d'Alverny <rda@mageia.org> | 2011-04-18 20:49:39 +0000 |
---|---|---|
committer | Romain d'Alverny <rda@mageia.org> | 2011-04-18 20:49:39 +0000 |
commit | e02417808c58c8c840a03072fbd078b7e9df043c (patch) | |
tree | f2a2c49d46c079ff235ccacade69570f6e675fa4 /index.php | |
parent | ef4eb4de8b819d274d805b6309f38c868fb2b8f0 (diff) | |
download | pkgsubmit-e02417808c58c8c840a03072fbd078b7e9df043c.tar pkgsubmit-e02417808c58c8c840a03072fbd078b7e9df043c.tar.gz pkgsubmit-e02417808c58c8c840a03072fbd078b7e9df043c.tar.bz2 pkgsubmit-e02417808c58c8c840a03072fbd078b7e9df043c.tar.xz pkgsubmit-e02417808c58c8c840a03072fbd078b7e9df043c.zip |
better sort function
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 26 |
1 files changed, 24 insertions, 2 deletions
@@ -361,9 +361,31 @@ if ($total > 0) { $s .= '</table><br /><br />'; $s .= '<table><caption>Build time</caption></tr><th></th><th></th></tr>'; - 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('<tr><td><td>%s</td><td>%d</td></tr>', + $s .= sprintf('<tr><td>%s</td><td>%d</td></tr>', $time, $count); } // TODO (rda) compute/show average for all builds |