I'm trying to order the list below of workers by the quantity of this days . But I can't get the right way to do that. I can order them by ID for example on this way:
workers.stream().sorted(Comparator.comparingInt(Worker::getId)).collect(Collectors.toList());
But I can't find the way to use the Worker.getDays().size() to order them....
"workers": [
{
"id": 1,
"days": ["Monday", "Wednesday", "Friday"]
},
{
"id": 2,
"days": ["Tuesday", "Thursday"]
},
{
"id": 3,
"days": ["Monday", "Tuesday", "Friday"]
},
{
"id": 4,
"days": ["Thursday"]
},
]
Hope I could find a nice solution, thanks in advance :)