]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Fix order of tags with the same number of occurrences
authorArthurHoaro <arthur@hoa.ro>
Sat, 19 May 2018 13:47:55 +0000 (15:47 +0200)
committerArthurHoaro <arthur@hoa.ro>
Sat, 19 May 2018 13:47:55 +0000 (15:47 +0200)
Fixes #1142

application/LinkDB.php

index c1661d52c972970e34f26b156f60b3012dd3cb97..ce53f200435f683051ee36216f432c58170a2d3b 100644 (file)
@@ -458,8 +458,10 @@ You use the community supported version of the original Shaarli project, by Seba
                 $tags[$caseMapping[strtolower($tag)]]++;
             }
         }
-        // Sort tags by usage (most used tag first)
-        arsort($tags);
+        $keys = array_keys($tags);
+        $tmpTags = array_combine($keys, $keys);
+        // We sort tags by DESC occurrences, then ASC alphabetically for equal values.
+        array_multisort($tags, SORT_DESC, $tmpTags, SORT_ASC, $tags);
         return $tags;
     }