From: cajus Date: Thu, 20 Aug 2009 14:33:30 +0000 (+0000) Subject: Added sorting for date and integer X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=364d355ab9f36ba804a1586714983b1d4b6feb6f;p=gosa.git Added sorting for date and integer git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14097 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/class_listingSortIterator.inc b/gosa-core/include/class_listingSortIterator.inc index 7f46512e5..14aef7630 100644 --- a/gosa-core/include/class_listingSortIterator.inc +++ b/gosa-core/include/class_listingSortIterator.inc @@ -52,11 +52,21 @@ class listingSortIterator implements Iterator { // Take a look at the several types switch ($_sortType) { case 'string': - return strnatcmp($a, $b); + return strcoll($a, $b); + + case 'integer': + return $b - $a; + + case 'date': + list($d, $m, $y)= split('\.', $a); + $a= (int)sprintf("%04d%02d%02d", $y, $m, $d); + list($d, $m, $y)= split('\.', $b); + $b= (int)sprintf("%04d%02d%02d", $y, $m, $d); + return $b-$a; // Sort for string by default default: - return strnatcmp($a, $b); + return strcoll($a, $b); } }