From efa9d4bec8bef6cccd1f0e3e30e3bc5d8b9a1204 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Sun, 2 Jul 2017 10:00:37 +0100 Subject: [PATCH] sidebar: stabilise sort order When sorting by a numeric type, fallback to the path if the numbers are the same. Fixes #486 --- sidebar.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sidebar.c b/sidebar.c index 68300dccb..ffdf7724c 100644 --- a/sidebar.c +++ b/sidebar.c @@ -285,16 +285,25 @@ static int cb_qsort_sbe(const void *a, const void *b) switch ((SidebarSortMethod & SORT_MASK)) { case SORT_COUNT: - result = (b2->msg_count - b1->msg_count); + if (b2->msg_count == b1->msg_count) + result = mutt_strcoll(b1->path, b2->path); + else + result = (b2->msg_count - b1->msg_count); break; case SORT_UNREAD: - result = (b2->msg_unread - b1->msg_unread); + if (b2->msg_unread == b1->msg_unread) + result = mutt_strcoll(b1->path, b2->path); + else + result = (b2->msg_unread - b1->msg_unread); break; case SORT_DESC: result = mutt_strcmp(b1->desc, b2->desc); break; case SORT_FLAGGED: - result = (b2->msg_flagged - b1->msg_flagged); + if (b2->msg_flagged == b1->msg_flagged) + result = mutt_strcoll(b1->path, b2->path); + else + result = (b2->msg_flagged - b1->msg_flagged); break; case SORT_PATH: { -- 2.40.0