Order and sorting

Yes, but I had a reason not to. That code ends up in the same place but does not include multisets (lists as sorted by msort/2) in the spec. The fact that I started elsewhere and ended up in the same place is interesting enough to me.

Either way, I would like to hear opinions on whether a new library (maybe distributed as an “add-on package”) is of any interest to anyone. We roughly have the following purely additive features not available at the moment in library(ordsets):

  • A spec that covers multisets as produced by msort/2 (already in the code I provided)
  • A C implementation of the same algorithms, if this makes it that much faster (I would know how to do it and the work seems mechanical enough. I specifically used compare/3 because it is available as PL_compare() in the foreign language interface)
  • A version of the predicates that takes a custom comparator.

This last one is not well defined at the moment. One possible way is to have the client code provide a comparison predicate like predsort/3, another would be to have some convention similar to sort/4 which covers a lot of use cases (but not all).

The only important question is if there is any use whatsoever for any of this. Until Stassa popped up with her questions a month ago, no one ever seems to have needed any of this :smiley: I would have needed it a couple of times but I just wrote custom code or circumvented the issue altogether.