The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
April 2000


where you can ask and answer Java programming questions."> - a resource for Java and Jini developers
Artima | Search | Java | Design | JVM | Jini | Books | Seminars | Subscribe 

Java Answers Forum
April 2000

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


Collections framework: is sort() always stable?

Posted by Steven Tolkin on April 24, 2000 at 5:45 PM

Is there a guarantee that sort() will be stable?
Suppose I implement a faster sort algorithm that is not stable.
For example one can sort integers in log log n (sic) time.
Am I "allowed" to use a non-stable sort for sort()?
If so code that depended on sort being stable will likely break.
Perhaps we should encourage naming this nonstableSort() as a
precaution. (This kind of guarantee is very hard to express,
even if "programming by contract" is later added to Java.
Does Eiffel have a solution to this? Or must we rely on
conventions, e.g. names for methods, etc.)


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us