X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/c3788d765ed4e7ddf00794085af757714bc102cf..c55c3657c32e1c11f0aa7811b6720d4a711f9abb:/lib-php/SimpleWordList.php 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;