swiftlang/swift-foundation

Sorting with multiple SortComparator uses a Sequence instead of Collection

Opened this issue · 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.