mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 06:21:14 +00:00
sortlistmodel: Make sort stable again
Previously, the sort was not stable when items were added/removed while sorting or the sort algorithm was changed. Now the sort looks at the item position (via the key's location in the keys array) to make sure each comparison stays stable with respect to this position.
This commit is contained in:
parent
eaaa287078
commit
c03383d3e5
@ -255,7 +255,11 @@ sort_func (gconstpointer a,
|
||||
gpointer *sb = (gpointer *) b;
|
||||
int result;
|
||||
|
||||
return gtk_sort_keys_compare (data, *sa, *sb);
|
||||
result = gtk_sort_keys_compare (data, *sa, *sb);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
return *sa < *sb ? -1 : 1;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
Loading…
Reference in New Issue
Block a user