From 503abb36a23dc8bb0ae5c08ede44e31712b12e53 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 28 Aug 2015 19:10:47 +0200 Subject: [PATCH] Sort languages with a name before those with language code only --- settings/personal.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/settings/personal.php b/settings/personal.php index bbbba3b5b8..8a1a8af55c 100644 --- a/settings/personal.php +++ b/settings/personal.php @@ -94,6 +94,15 @@ ksort($commonlanguages); // sort now by displayed language not the iso-code usort( $languages, function ($a, $b) { + if ($a['code'] === $a['name'] && $b['code'] !== $b['name']) { + // If a doesn't have a name, but b does, list b before a + return 1; + } + if ($a['code'] !== $a['name'] && $b['code'] === $b['name']) { + // If a does have a name, but b doesn't, list a before b + return -1; + } + // Otherwise compare the names return strcmp($a['name'], $b['name']); });