Generation

generate functionSat, 12 Nov 2022

sort a vector of integers

fn sort(v: &mut [i32]) { for i in 0..v.len() { let mut mini = i; for j in i+1..v.len() { if v[j] < v[mini] { mini = j; } } v.swap(i, mini); } }

Questions about programming?Chat with your personal AI assistant