From 69d584331d05de0d8732be2799c228b977b626d9 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Thu, 12 Apr 2012 23:02:24 +0200 Subject: [PATCH] OC_VCategories: sort categories in natural order using usort Use usort to sort, so that the json encoding is an array. --- lib/vcategories.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/vcategories.php b/lib/vcategories.php index 9d272eeabd..b3b6a493c8 100644 --- a/lib/vcategories.php +++ b/lib/vcategories.php @@ -64,6 +64,7 @@ class OC_VCategories { */ public function categories() { OC_Log::write('core','OC_VCategories::categories: '.print_r($this->categories, true), OC_Log::DEBUG); + usort($this->categories, 'strnatcasecmp'); // usort to also renumber the keys return $this->categories; } @@ -96,7 +97,6 @@ class OC_VCategories { } if(count($newones) > 0) { $this->categories = array_merge($this->categories, $newones); - natcasesort($this->categories); // Dunno if this is necessary if($sync === true) { $this->save(); } @@ -146,6 +146,7 @@ class OC_VCategories { * @brief Save the list with categories */ private function save() { + usort($this->categories, 'strnatcasecmp'); // usort to also renumber the keys $escaped_categories = serialize($this->categories); OC_Log::write('core','OC_VCategories::save: '.print_r($this->categories, true), OC_Log::DEBUG); OC_Preferences::setValue($this->user, $this->app, self::PREF_CATEGORIES_LABEL, $escaped_categories);