JuliaLang/julia — pull request #8792 by kmsquire (2014-10-23 20:55:37+00:00)
Title: Added sortperm!

* Allows preallocation (and therefore, reuse) of an index array
* Useful for https://github.com/JuliaLang/julia/pull/8316#issuecomment-60220521

One change which I'm unsure of here is loosening the types allowed for `lt(p::Perm, a, b)` from `Int` to `Integer`. I did it with the idea that, if a user is providing a preallocated array, she could choose to use a different integer type (e.g., a large `Int32` array might have better cache performance than `Int64`).

That said, restricting the `sortperm` array type to `Vector{Int}` would be fine as well. Thoughts?

Cc: @ViralBShah, @StefanKarpinski