assoc-utils icon indicating copy to clipboard operation
assoc-utils copied to clipboard

Suggestion: Use stable-sort in alist=

Open epipping opened this issue 7 years ago • 1 comments

It is common practice to have multiple entries in an alist with the same key. E.g. CLtL2 explicitly touts this as a feature:

Moreover, because the searching function assoc searches the a-list in order, new entries can ``shadow'' old entries

The order of keys should thus be maintained in alist=, otherwise this function might e.g. return non-nil for '(("foo" . 1) ("foo" . 2)) and '(("foo" . 2) ("foo" . 1)).

epipping avatar Sep 30 '16 13:09 epipping

@epipping could you please provide a test which will break because the sort is not stable?

svetlyak40wt avatar May 29 '20 18:05 svetlyak40wt