Is it possible to use the Java Collections sort method with a comparator to, as it sorts one list to also sort another list by the index of the original list so that the lists remains paired? Thanks.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You cannot do that with a Comparator. The solution to your problem is to build a third list that holds pairs of corresponding elements from the given lists. Then sort, and copy back to the original lists.