diff --git a/api/src/Etemplate/Widget/Taglist.php b/api/src/Etemplate/Widget/Taglist.php index 78abb77bafd..9ac30c24163 100644 --- a/api/src/Etemplate/Widget/Taglist.php +++ b/api/src/Etemplate/Widget/Taglist.php @@ -79,6 +79,13 @@ public static function ajax_search() { $results[] = array('id' => $id, 'label' => $name); } + + usort($results, function ($a, $b) use ($query) { + similar_text($query, $a["label"], $percent_a); + similar_text($query, $b["label"], $percent_b); + return $percent_a === $percent_b ? 0 : ($percent_a > $percent_b ? -1 : 1); + }); + // switch regular JSON response handling off Api\Json\Request::isJSONRequest(false);