sort_by_key

This commit is contained in:
Quaternions 2024-10-01 16:17:59 -07:00
parent a30893dcdf
commit ea76d137fd

View File

@ -63,7 +63,7 @@ impl ModesBuilder{
//collect modes and stages into contiguous arrays //collect modes and stages into contiguous arrays
let mut unique_modes:Vec<(gameplay_modes::ModeId,gameplay_modes::Mode)> let mut unique_modes:Vec<(gameplay_modes::ModeId,gameplay_modes::Mode)>
=self.modes.into_iter().collect(); =self.modes.into_iter().collect();
unique_modes.sort_by(|a,b|a.0.cmp(&b.0)); unique_modes.sort_by_key(|&(mode_id,_)|mode_id);
let (mut modes,final_mode_id_from_builder_mode_id):(Vec<ModeBuilder>,HashMap<gameplay_modes::ModeId,gameplay_modes::ModeId>) let (mut modes,final_mode_id_from_builder_mode_id):(Vec<ModeBuilder>,HashMap<gameplay_modes::ModeId,gameplay_modes::ModeId>)
=unique_modes.into_iter().enumerate() =unique_modes.into_iter().enumerate()
.map(|(final_mode_id,(builder_mode_id,mut mode))|{ .map(|(final_mode_id,(builder_mode_id,mut mode))|{