sort according to id

This commit is contained in:
Johannes Schmelz 2024-12-01 17:51:24 +01:00
parent 9bf9e8406b
commit 2f025e2e1a

View File

@ -18,8 +18,11 @@ import pp.monopoly.model.fields.FoodField;
import pp.monopoly.model.fields.GateField;
import pp.monopoly.model.fields.PropertyField;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
* PropertyOverviewMenu is a dialog for displaying the player's properties in the game.
@ -102,7 +105,7 @@ public class PropertyOverviewMenu extends Dialog {
}
// Iterate through the fetched properties
for (PropertyField property : fields) {
for (PropertyField property : fields.stream().sorted(Comparator.comparingInt(PropertyField::getId)).collect(Collectors.toList())) {
if (property instanceof BuildingProperty) {
BuildingProperty building = (BuildingProperty) property;
cards.add(createBuildingCard(building));