You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#[derive(Debug,Eq,Ord,PartialEq,PartialOrd)]structPerson{name:String,age:u32}implPerson{pubfnnew(name:String,age:u32) -> Self{Person{
name,
age
}}}fnmain(){letmut people = vec![Person::new("Zoe".to_string(),25),Person::new("Al".to_string(),60),Person::new("John".to_string(),1),];// Sort people by derived natural order (Name and age)
people.sort();// Sort people by age
people.sort_by(|a, b| b.age.cmp(&a.age));}