From 7e3833182db4553ce6ca399aaacbb91ec4b37b51 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 27 Nov 2009 14:25:58 +0000 Subject: [PATCH] optimized sorting --- lam/lib/lists.inc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lam/lib/lists.inc b/lam/lib/lists.inc index 53d7b1ad..eec72782 100644 --- a/lam/lib/lists.inc +++ b/lam/lib/lists.inc @@ -298,16 +298,12 @@ class lamList { * @return integer 0 if both are equal, 1 if $a is greater, -1 if $b is greater */ protected function cmp_array(&$a, &$b) { - // sort specifies the sort column - $sort = $this->sortColumn; - // sort by first column if no attribute is given - if (!$sort) $sort = strtolower($this->attrArray[0]); - if ($sort != "dn") { + if ($this->sortColumn != "dn") { // sort by first attribute with name $sort - return @strnatcasecmp($a[$sort][0], $b[$sort][0]) * $this->sortDirection; + return @strnatcasecmp($a[$this->sortColumn][0], $b[$this->sortColumn][0]) * $this->sortDirection; } else { - return strnatcasecmp($a[$sort], $b[$sort]) * $this->sortDirection; + return strnatcasecmp($a[$this->sortColumn], $b[$this->sortColumn]) * $this->sortDirection; } }