Anonymous user
Sort an integer array: Difference between revisions
→{{header|Ruby}}: add Rust solution
(Added zkl) |
(→{{header|Ruby}}: add Rust solution) |
||
Line 1,391:
sorted = nums.sort # returns a new sorted array. 'nums' is unchanged
nums.sort! # sort 'nums' "in-place"</lang>
=={{header|Rust}}==
Works with Rust 0.11-pre. Uses merge sort in place, allocating ~2*n memory where n is a length of an array.
<lang rust>fn main() {
let mut a = vec!(9, 8, 7, 6, 5, 4, 3, 2, 1, 0);
a.sort();
println!("{}", a);
}</lang>
=={{header|Scala}}==
|