Pitch [stdlib]: making sorting algorithm selectable

How about telling the stdlib what properties you need, and stdlib choosing the fastest implementation for you?

array.sort(properties: [.stable, .inPlace])

Some combinations would be impossible, but that could be checked if/when we have static assertions Compile-Time Constant Expressions for Swift

If having support on stdlib level, what @cukr suggests above seems like the only reasonable exposure of interface IMHO. As previously mentioned, it seems like a bad idea to commit to exposing specific algorithms. If specifying sort algo properties, it allows for the implementation to change (for the better :-) over time.

1 Like