Answer the question
In order to leave comments, you need to log in
How to sort a list of objects by field in another list of objects?
Help with sorting, you need to sort the list by the field of the object that is in another list
Here is an example structure, and you need to sort by value and a certain guid in 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": "[email protected]"
},
"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"
}
]
}
]
}
]
[
{
"user": {
"name": "Bob",
"email": "[email protected]"
},
"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"
}
]
}
]
}
]
Answer the question
In order to leave comments, you need to log in
Implement Comparable or Comparator, then standard sorting tools.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question