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

Showing 1-2 of 2 messages
Clojure sort: is it specified to be stable for all targets? Daniel Pittman 9/11/11 10:06 PM
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

Re: Clojure sort: is it specified to be stable for all targets? Stuart Sierra 9/12/11 4:48 PM
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