[swift-evolution] Add stableSort() to the standard library.
Daniel Vollmer
lists at maven.de
Mon Jan 11 09:40:34 CST 2016
Hello,
> On 11 Jan 2016, at 04:39, Dmitri Gribenko via swift-evolution <swift-evolution at swift.org> wrote:
[snip]
> I have been thinking about this, and even though other languages it is
> a separate function, since the fundamental operation of sort() and
> stableSort() seems sufficiently similar to me, the defaulted parameter
> seems like the right thing to do. What other parameters could sort()
> conceivably get in future? Should the parameter be a boolean flag or
> a resilient option set?
Whether a sort should be stable or not doesn’t really strike me as a (variable) parameter (i.e. context of the sort() call determines whether a stable sort is needed). I would also assume that the algorithms implemented would be different for stable vs. unstable (unless of course unstable sort is implemented in terms of stable sort). Both of these would make me (very slightly) prefer separate methods.
That being said, once additional variations / flags come into play, it seems like a bad idea to have distinct methods for all compile-time fixed “parameter”-combinations.
*shrug*
Daniel.
More information about the swift-evolution
mailing list