Created
August 2, 2017 15:19
-
-
Save silphire/4cf8468baa1f748e572fc0165a1f4a7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn sort(data: &mut Vec<i32>) { | |
for i in 0..data.len() { | |
for j in i..data.len() { | |
if data[i] > data[j] { | |
data.swap(i, j); | |
} | |
} | |
} | |
} | |
fn main() { | |
let mut a = vec![5, 2, 4, 3, 1]; | |
sort(&mut a); | |
for i in 0..a.len() { | |
print!("{} ", a[i]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment