From 55b3811debe4f89b8c7f1e1eedfb151ce0df46cf Mon Sep 17 00:00:00 2001 From: Mei Chang van der Werff Date: Thu, 22 Jan 2026 01:08:54 +0100 Subject: [PATCH] Sorts ingredients in alphabetic order --- .../java/client/scenes/recipe/IngredientListCtrl.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/client/src/main/java/client/scenes/recipe/IngredientListCtrl.java b/client/src/main/java/client/scenes/recipe/IngredientListCtrl.java index 7bb392f..679e05d 100644 --- a/client/src/main/java/client/scenes/recipe/IngredientListCtrl.java +++ b/client/src/main/java/client/scenes/recipe/IngredientListCtrl.java @@ -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 ingredientList = recipe.getIngredients(); + List ingredientList = recipe + .getIngredients() + .stream() + .sorted(Comparator.comparing(ingredient -> ingredient + .getIngredient() + .getName())) + .toList(); this.ingredients = FXCollections.observableArrayList(ingredientList); }