Skip to content

Instantly share code, notes, and snippets.

@silphire
Created August 2, 2017 15:19
Show Gist options
  • Save silphire/4cf8468baa1f748e572fc0165a1f4a7b to your computer and use it in GitHub Desktop.
Save silphire/4cf8468baa1f748e572fc0165a1f4a7b to your computer and use it in GitHub Desktop.
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