Sorts ingredients in alphabetic order
This commit is contained in:
parent
83910eca72
commit
55b3811deb
1 changed files with 8 additions and 1 deletions
|
|
@ -8,6 +8,7 @@ import com.google.inject.Inject;
|
||||||
import commons.FormalIngredient;
|
import commons.FormalIngredient;
|
||||||
import commons.Recipe;
|
import commons.Recipe;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
|
@ -78,7 +79,13 @@ public class IngredientListCtrl implements LocaleAware {
|
||||||
if (recipe == null) {
|
if (recipe == null) {
|
||||||
this.ingredients = FXCollections.observableArrayList(new ArrayList<>());
|
this.ingredients = FXCollections.observableArrayList(new ArrayList<>());
|
||||||
} else {
|
} 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);
|
this.ingredients = FXCollections.observableArrayList(ingredientList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue