Commit 83dab27e 83dab27ec074a3033c9e6344b4f58fbb6aa8825e by Sergey Poznyakoff

Stable sort

1 parent ecfff4ca
...@@ -292,7 +292,7 @@ compare_action (void *item, void *data) ...@@ -292,7 +292,7 @@ compare_action (void *item, void *data)
292 } 292 }
293 293
294 static int 294 static int
295 compare_messages (mu_message_t a, mu_message_t b) 295 compare_messages (mu_message_t a, mu_message_t b, size_t anum, size_t bnum)
296 { 296 {
297 struct comp_data d; 297 struct comp_data d;
298 298
...@@ -300,6 +300,14 @@ compare_messages (mu_message_t a, mu_message_t b) ...@@ -300,6 +300,14 @@ compare_messages (mu_message_t a, mu_message_t b)
300 d.m[0] = a; 300 d.m[0] = a;
301 d.m[1] = b; 301 d.m[1] = b;
302 mu_list_do (oplist, compare_action, &d); 302 mu_list_do (oplist, compare_action, &d);
303 if (d.r == 0)
304 {
305 if (anum < bnum)
306 d.r = -1;
307 else if (anum > bnum)
308 d.r = 1;
309 }
310
303 if (verbose > 1) 311 if (verbose > 1)
304 fprintf (stderr, "%d\n", d.r); 312 fprintf (stderr, "%d\n", d.r);
305 return d.r; 313 return d.r;
...@@ -380,7 +388,7 @@ comp0 (size_t na, size_t nb) ...@@ -380,7 +388,7 @@ comp0 (size_t na, size_t nb)
380 _("comparing messages %s and %s: "), 388 _("comparing messages %s and %s: "),
381 mu_umaxtostr (0, na), 389 mu_umaxtostr (0, na),
382 mu_umaxtostr (1, nb)); 390 mu_umaxtostr (1, nb));
383 return compare_messages (a, b); 391 return compare_messages (a, b, na, nb);
384 } 392 }
385 393
386 int 394 int
......