Randomness in built-in .sort
Sean Kelly
sean at invisibleduck.org
Tue Jan 6 10:56:24 PST 2009
== Quote from Walter Bright (newshound1 at digitalmars.com)'s article
> Bill Baxter wrote:
> > It seems to me that the built-in .sort uses a randomized algorithm
> > that leads to results that differ from run-to-run when there are
> > elements with identical keys.
> No, it doesn't use random sorts. The source code is included, so this
> should be easy to verify.
I don't know if it helps, but the built-in sort uses a similar algorithm
to the sort routine in tango.core.Array. It picks a "median of 3" value
for the pivot. As Walter said, I don't believe any randomness is involved.
Sean
More information about the Digitalmars-d
mailing list