Head's Up: JavaScript is either turned off or not working properly in your browser. Some parts of this page may not work properly.
fn main() { let mut items = vec!["1.txt", "10.txt", "2.txt"]; items.sort_by(|a, b| { let a_num: u32 = a.split(".").collect::<Vec<&str>>()[0].parse().expect("parse"); let b_num: u32 = b.split(".").collect::<Vec<&str>>()[0].parse().expect("parse"); a_num.cmp(&b_num) }); dbg!(items); }
[_active_nvim_run:8:3] items = [ "1.txt", "2.txt", "10.txt", ]