]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib-php/SimpleWordList.php
don't even try heavily penalized searches
[nominatim.git] / lib-php / SimpleWordList.php
index ecd02153da7439b947e0899e5a176b17be033273..7009d370f9bb0e992f49eb47547ce5ef950b0f5b 100644 (file)
@@ -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;