Use unsafe code in Rust sort function.

Change the Rust implementation of sort to use unsafe code in the tight
loops. This results in approximately C++ perf.