diff --git a/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/evolution/EvolutionFragment.kt b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/evolution/EvolutionFragment.kt index a29bf8f..dd5b012 100644 --- a/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/evolution/EvolutionFragment.kt +++ b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/evolution/EvolutionFragment.kt @@ -41,9 +41,10 @@ class EvolutionFragment : Fragment() { pokemonValue?.let { pokemon -> val evolutions = pokemon.evolutions ?: emptyList() dashboardViewModel.getPokemonEvolutionsByIds(evolutions) - .observe(viewLifecycleOwner, Observer { - val pokemons: List = it - adapter.setList(pokemons) + .observe(viewLifecycleOwner, Observer { pokemons -> + val sortedEvolutionIds = pokemon.evolutions + adapter.setList(pokemons.sortedBy { sortedEvolutionIds?.indexOf(it.id) }) + adapter.notifyDataSetChanged() if (pokemons.isEmpty()) {