X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/efafa5271957fb54b356ec1c90e8613f14de40d4..b01a836d1ecce5c7cc1aceedf19535eeda9058af:/lib-php/SimpleWordList.php?ds=sidebyside diff --git a/lib-php/SimpleWordList.php b/lib-php/SimpleWordList.php index ecd02153..7009d370 100644 --- a/lib-php/SimpleWordList.php +++ b/lib-php/SimpleWordList.php @@ -120,13 +120,18 @@ class SimpleWordList return array_slice($aWordSets, 0, SimpleWordList::MAX_WORDSETS); } + /** + * Custom search routine which takes two arrays. The array with the fewest + * items wins. If same number of items then the one with the longest first + * element wins. + */ public static function cmpByArraylen($aA, $aB) { $iALen = count($aA); $iBLen = count($aB); if ($iALen == $iBLen) { - return 0; + return strlen($aB[0]) <=> strlen($aA[0]); } return ($iALen < $iBLen) ? -1 : 1;