summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-04-12 23:02:24 +0200
committerBart Visscher <bartv@thisnet.nl>2012-04-12 23:10:49 +0200
commit69d584331d05de0d8732be2799c228b977b626d9 (patch)
tree8c313fb8b3afee4d7f58637dae818950cf8b4131
parentb2011bd0a01e9084a7fc1d5a04ed02a29c69ac4b (diff)
downloadnextcloud-server-69d584331d05de0d8732be2799c228b977b626d9.tar.gz
nextcloud-server-69d584331d05de0d8732be2799c228b977b626d9.zip
OC_VCategories: sort categories in natural order using usort
Use usort to sort, so that the json encoding is an array.
-rw-r--r--lib/vcategories.php3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/vcategories.php b/lib/vcategories.php
index 9d272eeabd4..b3b6a493c8d 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);