[swift-evolution] [Idea] Bringing the partial/total ordering distinction into Comparable

Brent Royal-Gordon brent at brentdax.com
Sun Apr 24 16:05:28 CDT 2016

> Regarding how this affects sorting methods though, some people (myself included) like the simplicity of being able to do the following:
> 	myArray.sort(>)	// If array is of Comparable elements, just throw in the operator

That is extremely convenient. With my proposed extensions, it's actually writeable as this:

	myArray.sorted { ($0 <=> $1).reversed() }

But that's obviously much less convenient. It's also equivalent to this:

	myArray.sorted { $1 <=> $0 }

Which means, with the proper higher-order function, it's the same as this:


Brent Royal-Gordon

More information about the swift-evolution mailing list