Is there is a built-in method in Java to sort a 2D array directly
For example: if I have an array of first name & phone number, can I sort it according to the first name while each name will keep it’s phone number using built-in function?
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.
Is your data structure
[[name1, name2, ...], [phone1, phone2,...]]or[[name1, phone1], ...]? If it’s the latter, you can use a comparator.Then use Arrays.sort