Sorting list based on another list's order [duplicate]
问题 This question already has answers here : Guava way of sorting List according to another list? (5 answers) Closed 3 years ago . I need to sort a list of Person objects( List<Person> , where each Person object has few attributes like id (unique), name , age … etc). The sorting order is based on another list. That list contains a set of Person id 's (A List<String> which is already sorted). What is the best way to order the List<Person> in the same order as the list of id 's using Kotlin or Java