Помогите с сортировкой, нужно отсортировать список, по полю объекта который в другом списке
Вот структура примерная структура, и сортировать нужно по value и определенному guid в Priority
class ResponseData {
private User user;
private List<Event> event;
public static User {
private String name;
private String email;
}
public static class Event {
private String guid;
private List<Priority> priority;
}
public static class Priority {
private String guid;
private String name;
private String value;
}
}
Пример входных данных:
[
{
"user": {
"name": "Bob",
"email": "bob@gmail.com"
},
"event": [
{
"guid": "1",
"priority": [
{
"guid": "sport",
"name": "Sport",
"value": "35.29"
},
{
"guid": "work",
"name": "work",
"value": "25.19"
},
{
"guid": "hobby",
"name": "hobby",
"value": "85.98"
}
]
},
{
"guid": "2",
"priority": [
{
"guid": "sport",
"name": "Sport",
"value": "14.19"
},
{
"guid": "work",
"name": "work",
"value": "75.19"
},
{
"guid": "hobby",
"name": "hobby",
"value": "75.98"
}
]
},
{
"guid": "3",
"priority": [
{
"guid": "sport",
"name": "Sport",
"value": "95.29"
},
{
"guid": "work",
"name": "work",
"value": "29.19"
},
{
"guid": "hobby",
"name": "hobby",
"value": "65.98"
}
]
},
{
"guid": "4",
"priority": [
{
"guid": "sport",
"name": "Sport",
"value": "99.29"
},
{
"guid": "work",
"name": "work",
"value": "19.19"
},
{
"guid": "hobby",
"name": "hobby",
"value": "85.98"
}
]
},
{
"guid": "5",
"priority": [
{
"guid": "sport",
"name": "Sport",
"value": "97.29"
},
{
"guid": "work",
"name": "work",
"value": "39.19"
},
{
"guid": "hobby",
"name": "hobby",
"value": "95.98"
}
]
}
]
}
]
Далее нужно сортировать список event по value в priority где guid равен sport
в результате получим что спсиок ивентов буде 2, 1, 3, 5, 4
Вот пример сортировки:
[
{
"user": {
"name": "Bob",
"email": "bob@gmail.com"
},
"event": [
{
"guid": "2",
"priority": [
{
"guid": "sport",
"name": "Sport",
"value": "14.19"
},
{
"guid": "work",
"name": "work",
"value": "75.19"
},
{
"guid": "hobby",
"name": "hobby",
"value": "75.98"
}
]
},
{
"guid": "1",
"priority": [
{
"guid": "sport",
"name": "Sport",
"value": "35.29"
},
{
"guid": "work",
"name": "work",
"value": "25.19"
},
{
"guid": "hobby",
"name": "hobby",
"value": "85.98"
}
]
},
{
"guid": "3",
"priority": [
{
"guid": "sport",
"name": "Sport",
"value": "95.29"
},
{
"guid": "work",
"name": "work",
"value": "29.19"
},
{
"guid": "hobby",
"name": "hobby",
"value": "65.98"
}
]
},
{
"guid": "5",
"priority": [
{
"guid": "sport",
"name": "Sport",
"value": "97.29"
},
{
"guid": "work",
"name": "work",
"value": "39.19"
},
{
"guid": "hobby",
"name": "hobby",
"value": "95.98"
}
]
},
{
"guid": "4",
"priority": [
{
"guid": "sport",
"name": "Sport",
"value": "99.29"
},
{
"guid": "work",
"name": "work",
"value": "19.19"
},
{
"guid": "hobby",
"name": "hobby",
"value": "85.98"
}
]
}
]
}
]