Added sortperm!

* Allows preallocation (and therefore, reuse) of an index array
* Useful for #8316
Merge pull request #8792 from JuliaLang/kms/sortperm!

Added sortperm!