I can’t really think of a reason why this isn’t offered by the OrderedCollections package. There are in-place sort() (see the documentation) methods for this, so the behavior is well-defined. The only thing I can think of is that it discourages unintentional copies of the underlying buffers, but that same argument would apply to the collections in the standard library and that doesn’t prevent it from having these methods.
So is there a reason I’m not seeing? Or is this just not (yet?) implemented?
The unfortunate thing with the default sorted() is that it returns [Element] and not OrderedSet<Element> and OrderedDictionary<Key, Value>, respectively. In this case, those would be very useful to have.
To achieve that, you're of course free to shadow the Sequence extension methods with your own ones like the code below, but it would be nice if these were part of the Collections library already[1]:
Thanks everybody, this was helpful! I don’t know how I missed the default Sequence implementation (either in the docs or in code), but as @pyrtsa mentioned, this doesn’t really do what I wanted, i.e. return a copy that is sorted. I’m already using the exact shadowing implementation mentioned above to work around this.