mikuli.cz

:)
git clone https://git.sr.ht/~ashymad/mikuli.cz
Log | Files | Refs

commit 0b4ad495ae24cc21e62d1cd0d1bc883ab869a768
parent 872474ebe4fb1a118bce84357fc1bcce834f47ad
Author: markseu <mark2011@mayberg.se>
Date:   Tue, 21 Mar 2017 16:48:31 +0100

System update (stable sort)

Diffstat:
Msystem/plugins/core.php | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/system/plugins/core.php b/system/plugins/core.php @@ -1087,13 +1087,15 @@ class YellowPageCollection extends ArrayObject // Sort page collection by meta data function sort($key, $ascendingOrder = true) { + $array = $this->getArrayCopy(); + foreach($array as $page) $page->set("sortindex", ++$i); $callback = function($a, $b) use ($key, $ascendingOrder) { - return $ascendingOrder ? + $result = $ascendingOrder ? strnatcasecmp($a->get($key), $b->get($key)) : strnatcasecmp($b->get($key), $a->get($key)); + return $result==0 ? $a->get("sortindex") - $b->get("sortindex") : $result; }; - $array = $this->getArrayCopy(); usort($array, $callback); $this->exchangeArray($array); return $this; @@ -1125,7 +1127,7 @@ class YellowPageCollection extends ArrayObject } } $this->exchangeArray($array); - $this->sort("modified", false)->sort("searchscore", $ascendingOrder); + $this->sort("modified", $ascendingOrder)->sort("searchscore", $ascendingOrder); } return $this; }