]> granicus.if.org Git - neomutt/commitdiff
sidebar: stabilise sort order
authorRichard Russon <rich@flatcap.org>
Sun, 2 Jul 2017 09:00:37 +0000 (10:00 +0100)
committerRichard Russon <rich@flatcap.org>
Sun, 2 Jul 2017 21:37:20 +0000 (22:37 +0100)
When sorting by a numeric type, fallback to the path if the numbers are
the same.

Fixes #486

sidebar.c

index 68300dccbd60cad7f8e0b87cf5fb4c43d720843d..ffdf7724c808765ae512b5c5cd3f2921a4b5f98a 100644 (file)
--- 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:
     {