From 5c6b3b4a97440adecc120ce05262cecca2576e36 Mon Sep 17 00:00:00 2001 From: Jacek Kowalski <Jacek@jacekk.info> Date: Fri, 17 Mar 2017 11:50:38 +0000 Subject: [PATCH] Add missing stop Wzgórza Krzesławickie --- stops.php | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/stops.php b/stops.php index b9b0132..86abb6b 100644 --- a/stops.php +++ b/stops.php @@ -46,18 +46,24 @@ // Build structure for UI $stop_list = []; + $query_lower = mb_strtolower($_GET['query'], 'UTF-8'); foreach($ids as $id) { $stop_list[] = [ 'id' => $id, 'name' => $stops[$id], 'type' => 'stop', - 'relevance' => similar_text($_GET['query'], $stops[$id]) + 'relevance' => similar_text( + $query_lower, + mb_strtolower($stops[$id], 'UTF-8') + ) ]; } // Sort stops by relevence usort($stop_list, function($a, $b) { - return $b['relevance'] - $a['relevance']; + $rel = $b['relevance'] - $a['relevance']; + if($rel == 0) return strcasecmp($a['name'], $b['name']); + return $rel; }); // Return JSON -- Gitblit v1.9.1