From: Timo Sirainen Date: Tue, 26 Jul 2011 12:04:57 +0000 (+0300) Subject: lib-storage: Sorting by relevancy returned messages in reverse order. X-Git-Tag: 2.1.alpha1~210 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65c3bc9662eee5fcb889360458cbcdfba88bcc74;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Sorting by relevancy returned messages in reverse order. --- diff --git a/src/lib-storage/index/index-sort.c b/src/lib-storage/index/index-sort.c index b15e00260a..8889a7071f 100644 --- a/src/lib-storage/index/index-sort.c +++ b/src/lib-storage/index/index-sort.c @@ -209,7 +209,12 @@ index_sort_list_finish_float(struct mail_search_sort_program *program) { ARRAY_TYPE(mail_sort_node_float) *nodes = program->context; + /* NOTE: higher relevancy is returned first, unlike with all + other number based sort keys, so temporarily reverse the search */ + static_node_cmp_context.reverse = !static_node_cmp_context.reverse; array_sort(nodes, sort_node_float_cmp); + static_node_cmp_context.reverse = !static_node_cmp_context.reverse; + memcpy(&program->seqs, nodes, sizeof(program->seqs)); i_free(nodes); program->context = NULL; @@ -519,8 +524,10 @@ int index_sort_node_cmp_type(struct mail *mail, mail_set_seq(mail, seq2); float2 = index_sort_get_relevancy(mail); - ret = float1 < float2 ? -1 : - (float1 > float2 ? 1 : 0); + /* NOTE: higher relevancy is returned first, unlike with all + other number based sort keys */ + ret = float1 < float2 ? 1 : + (float1 > float2 ? -1 : 0); break; case MAIL_SORT_POP3_ORDER: /* 32bit numbers would be enough, but since there is already