Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9223437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:04:52+00:00 2026-06-18T04:04:52+00:00

Is there is a built-in method in Java to sort a 2D array directly

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:04:54+00:00Added an answer on June 18, 2026 at 4:04 am

    Is your data structure [[name1, name2, ...], [phone1, phone2,...]] or [[name1, phone1], ...]? If it’s the latter, you can use a comparator.

    class NameAndPhoneComparator implements Comparator<String[]> {
        public int compare(String[] o1, String[] o2) {
            int c = o1[0].compareTo(o2[0]);
            if (c != 0) return c;
            return o1[1].compareTo(o2[1]);
        }
    }
    

    Then use Arrays.sort

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does java have a built-in method to compare precedence of two operators? For example,
Is there a built in method in a java library that can compute 'N
Is there a built-in method to search a java.util.List specifying the first item to
There is no built in reverse method for Python's str object. How can I
Is there a way to shutdown a computer using a built-in Java method?
Is there any built-in method in Java to find the size of any datatype?
Is there any built-in method in Java which allows us to convert comma separated
In Java there is a method splitByCharacterType that takes a string, for example 0015j8*(
Is there any built-in method in OpenCV ( C++ API ) to subtract two
Is there a built-in data structure in Java to represent a Crit-bit tree? Or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.