问题
I am trying to sort a collection of linked-list nodes. The collection contains nodes from more than one linked list; ordering must be maintained within each list, but ordering across lists does not matter.
PartialOrdering[T]
seems like the natural choice, but I cannot find any standard functions within Scala that support it (e.g. .sort
only takes Ordering[T]
).
I've considered wrapping the former type into the latter, but realise this will actually produce erroneous results. Partial ordering cannot be abstracted-away like this as the underlying sort algorithm needs the additional information to produce correct results.
I would like to represent the elements as a SortedSet
- is anyone aware of anything that can get me close?
来源:https://stackoverflow.com/questions/23054115/partially-sorting-collections-in-scala