From acfc1a1907aca06adbfb5d28b720f4552381640d Mon Sep 17 00:00:00 2001 From: guinux Date: Fri, 2 Sep 2016 15:45:24 +0200 Subject: [PATCH] improve custom sort function for search results --- src/daemon.vala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/daemon.vala b/src/daemon.vala index a5d231b..9b1d2bc 100644 --- a/src/daemon.vala +++ b/src/daemon.vala @@ -52,21 +52,39 @@ private int alpm_pkg_sort_search_by_relevance (Alpm.Package pkg_a, Alpm.Package return 1; } if (pkg_a.name.has_prefix (global_search_string + "-")) { + if (pkg_b.name.has_prefix (global_search_string + "-")) { + return strcmp (pkg_a.name, pkg_b.name); + } return 0; } if (pkg_b.name.has_prefix (global_search_string + "-")) { + if (pkg_a.name.has_prefix (global_search_string + "-")) { + return strcmp (pkg_a.name, pkg_b.name); + } return 1; } if (pkg_a.name.has_prefix (global_search_string)) { + if (pkg_b.name.has_prefix (global_search_string)) { + return strcmp (pkg_a.name, pkg_b.name); + } return 0; } if (pkg_b.name.has_prefix (global_search_string)) { + if (pkg_a.name.has_prefix (global_search_string)) { + return strcmp (pkg_a.name, pkg_b.name); + } return 1; } if (pkg_a.name.contains (global_search_string)) { + if (pkg_b.name.contains (global_search_string)) { + return strcmp (pkg_a.name, pkg_b.name); + } return 0; } if (pkg_b.name.contains (global_search_string)) { + if (pkg_a.name.contains (global_search_string)) { + return strcmp (pkg_a.name, pkg_b.name); + } return 1; } }