Clojure sort: is it specified to be stable for all targets?

Sett 128 ganger
Hopp til første uleste melding

Daniel Pittman

ulest,
12. sep. 2011, 01:06:4112.09.2011
til clo...@googlegroups.com
G'day.

The API documentation for clojure doesn't specify if the sort method
is stable, unstable, or "implementation defined".

Java defines sort to be stable, but Clojure also has two other
targets, and I can't tell if I am safe making the assumption that the
stable behaviour will carry over to them, or if they will just have
whatever the implementor decided.

Daniel
--
♲ Made with 100 percent post-consumer electrons

Stuart Sierra

ulest,
12. sep. 2011, 19:48:4212.09.2011
til clo...@googlegroups.com
In general, if it's not specified in the doc string, then it's not a promise. That said, the implementation of `sort` in Clojure on the JVM uses java.util.Arrays#sort, which is specified to be stable.

I would generally expect a language built-in `sort` routine to be stable, so take that for what it's worth.

-Stuart Sierra
clojure.com
Svar alle
Svar til forfatter
Videresend
0 nye meldinger