From 36622101ae7c41b3b5b7eca2afe266466b99c34d Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 16 Jun 2015 18:36:12 +0200 Subject: [PATCH] Use built-in php sort functions refs #8205 --- .../application/views/helpers/Perfdata.php | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/modules/monitoring/application/views/helpers/Perfdata.php b/modules/monitoring/application/views/helpers/Perfdata.php index 1ff59b6ae..aaf6b3fee 100644 --- a/modules/monitoring/application/views/helpers/Perfdata.php +++ b/modules/monitoring/application/views/helpers/Perfdata.php @@ -19,19 +19,12 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract public function perfdata($perfdataStr, $compact = false, $limit = 0, $color = Perfdata::PERFDATA_OK) { $pieChartData = PerfdataSet::fromString($perfdataStr)->asArray(); - - if (1 < ($i = count($pieChartData))) { - while (--$i) { - for ($j = 0, $k = 1; $j < $i; ++$j, ++$k) { - if ($pieChartData[$k]->worseThan($pieChartData[$j])) { - $perfdata = $pieChartData[$k]; - $pieChartData[$k] = $pieChartData[$j]; - $pieChartData[$j] = $perfdata; - } - } + uasort( + $pieChartData, + function($a, $b) { + return $a->worseThan($b) ? -1 : ($b->worseThan($a) ? 1 : 0); } - } - + ); $results = array(); $table = array( '' . implode(