From: ArthurHoaro Date: Sat, 19 May 2018 13:47:55 +0000 (+0200) Subject: Fix order of tags with the same number of occurrences X-Git-Tag: v0.10.0~22^2~1 X-Git-Url: https://git.immae.eu/?p=github%2Fshaarli%2FShaarli.git;a=commitdiff_plain;h=f28396a2f82fe61af05f19c1df367f4c660655ab Fix order of tags with the same number of occurrences Fixes #1142 --- diff --git a/application/LinkDB.php b/application/LinkDB.php index c1661d52..ce53f200 100644 --- a/application/LinkDB.php +++ b/application/LinkDB.php @@ -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; }