diff --git a/src/fetch.rs b/src/fetch.rs index 2574f67..c4ae267 100644 --- a/src/fetch.rs +++ b/src/fetch.rs @@ -234,12 +234,12 @@ fn read_pokemon_file( } fn transform_pokemon_data( - pokemons: &std::collections::HashMap, + pokemon_collection: &std::collections::HashMap, ) -> Vec { - let mut processed_pokemons: Vec = pokemons + let mut processed_pokemons: Vec = pokemon_collection .iter() .map(|(_key, p)| { - let forms = p + let mut forms = p .gen_8 .forms .keys() @@ -249,6 +249,14 @@ fn transform_pokemon_data( }) .collect::>(); + // ensure `regular` is first then sort remaining forms alphabetically + // ocd af + forms.sort(); + if let Some(pos) = forms.iter().position(|x| x == "regular") { + forms.remove(pos); + forms.insert(0, "regular".to_string()); + } + ProcessedPokemon { // remove leading zeros from the pokedex number pokedex: p.idx.trim_start_matches('0').to_string(),