From 67ea013b0dcfac6794e7e3095c95fe02e19621cc Mon Sep 17 00:00:00 2001 From: Larry Price Date: Wed, 28 Sep 2016 20:49:21 -0400 Subject: [PATCH] If search results are going to be sorted, it makes sense for higher scores to be at the top of the list. Fixes #77. --- src/as-pool.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/as-pool.c b/src/as-pool.c index ee8f5465f..c80c370c3 100644 --- a/src/as-pool.c +++ b/src/as-pool.c @@ -1045,7 +1045,8 @@ as_pool_build_search_terms (AsPool *pool, const gchar *search) /** * as_sort_components_by_score_cb: * - * Helper method to sort result arrays by the #AsComponent match score. + * Helper method to sort result arrays by the #AsComponent match score + * with higher scores appearing higher in the list. */ static gint as_sort_components_by_score_cb (gconstpointer a, gconstpointer b) @@ -1056,9 +1057,9 @@ as_sort_components_by_score_cb (gconstpointer a, gconstpointer b) s1 = as_component_get_sort_score (cpt1); s2 = as_component_get_sort_score (cpt2); - if (s1 < s2) - return -1; if (s1 > s2) + return -1; + if (s1 < s2) return 1; return 0; } @@ -1069,7 +1070,7 @@ as_sort_components_by_score_cb (gconstpointer a, gconstpointer b) * @search: A search string * * Search for a list of components matching the search terms. - * The list will be unordered. + * The list will be ordered by match score. * * Returns: (transfer container) (element-type AsComponent): an array of the found #AsComponent objects. *