I have a class like the following,
public class Inventory {
private String name;
private List<Sample> samples;
}
public class Sample {
private int count;
private String date;
}
List<Inventory> inventories;
I have sorted the samples by date. It's fine. But I need to sort the inventories list by date field inside Sample class. samples are already sorted. So I need the inventories to sort by samples date DESC. For example,
Inside that inventories list, if it has 3 data,
Inventory 1
name = 1
samples has dates of = List of (2021-07-02, 2021-07-03)
Inventory 2
name = 2
samples has dates of = List of (2021-07-02, 2021-09-03, 2021-10-03)
Inventory 3
name = 3
samples has dates of = List of (2021-08-02, 2021-09-03)
So it should sort by date DESC and in that inventories list, it should have the data following way,
Inventory 1
Inventory 3
Inventory 2