Merge branch 'fix/Ingredients-ordered' into 'main'

Sorts ingredients in alphabetic order

Closes #75

See merge request cse1105/2025-2026/teams/csep-team-76!80
This commit is contained in:
Mei Chang van der Werff 2026-01-22 16:43:47 +01:00
commit 9077df5164

View file

@ -8,6 +8,7 @@ import com.google.inject.Inject;
import commons.FormalIngredient;
import commons.Recipe;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.function.Consumer;
@ -78,7 +79,13 @@ public class IngredientListCtrl implements LocaleAware {
if (recipe == null) {
this.ingredients = FXCollections.observableArrayList(new ArrayList<>());
} else {
List<RecipeIngredient> ingredientList = recipe.getIngredients();
List<RecipeIngredient> ingredientList = recipe
.getIngredients()
.stream()
.sorted(Comparator.comparing(ingredient -> ingredient
.getIngredient()
.getName()))
.toList();
this.ingredients = FXCollections.observableArrayList(ingredientList);
}