swift-foundation icon indicating copy to clipboard operation
swift-foundation copied to clipboard

Sorting with multiple SortComparator uses a Sequence instead of Collection

Open james-kwong opened this issue 1 year ago • 0 comments

I see there is a function to sort a Sequence of elements using any Sequence of SortComparator here:

https://github.com/apple/swift-foundation/blob/main/Sources/FoundationEssentials/SortComparator.swift#L234

However, shouldn't the sequence of sort comparators being passed to sorted be of type Collection instead? Because a Sequence doesn't mandate the ability to iterate non-destructively, but the sorted function iterates through the provided Sequence multiple times.

james-kwong avatar Aug 18 '24 21:08 james-kwong