I have an Arraylist which contains recipies and each recipe contains a list of ingredients. The recipies is shown in a UI list of an Android app and the useres wants to sort the list based on the ingredients they like most.
For example this is the list of ingredients they like most
1 - Cheese
2 - Potato
3 - Tuna
4 - Chicken
So the list of recipies shall show first all the ingredients that contains cheese and then potato etc.
How do I archive this with java stream()
?
Here is how my model classes is at the moment
public class Recipe {
String[] ingredients;
private String description;
private String title;
public String[] getIngredients() {
return ingredients;
}
public void setIngredients(String[] ingredients) {
this.ingredients = ingredients;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
.
public class Ingredient {
String title;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}