X-Git-Url: https://git.openstreetmap.org/nominatim.git/blobdiff_plain/c3788d765ed4e7ddf00794085af757714bc102cf..26688ba35d8fb642118794f968fc6aaf82596a3d:/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;