The sort was being made "stable" by comparing variables' addresses in
memory. There's nothing particularly predictable about that, especially
from one malloc implementation to another. This commit fixes the stability
by comparing the variables' dictionary indexes instead.
Bug #52072.
/* Make this a stable sort. */
if (!retval)
- retval = a < b ? -1 : a > b;
+ {
+ size_t a_index = var_get_dict_index (a);
+ size_t b_index = var_get_dict_index (b);
+ retval = a_index < b_index ? -1 : a_index > b_index;
+ }
if (c->descending)
retval = -retval;