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

  • SEARCH
  • Home
  • 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 6792087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:55:32+00:00 2026-05-26T17:55:32+00:00

On my quest learning Java I come across one doubt. For sorting a unidimensional

  • 0

On my quest learning Java I come across one doubt.

For sorting a unidimensional array we can use Arrays.sort() but if I want to sort a bidimensional array based on three columns? Is there any option to d that or do I have to code it for my self (something like three nested loops)?

Here is an example input:

13  2   28  36  
1   4   56  17  
4   2   5   40  
2   4   41  55  
9   5   48  12  
19  2   25  12  
20  5   13  8   
15  3   51  30  
12  5   39  59  
17  3   56  40  
3   1   56  46  
7   3   28  51  
8   5   14  58  
5   3   34  15  
14  4   53  2   
18  4   38  57  
6   2   16  25  
16  3   17  13  
10  5   41  33  
11  1   13  57  

Columns are int and this is stored in an array of ints.

I wanna sort by column 2, if equal numbers are found, then sort by column 3 and finally, if equals found, sort by column 3.

The output should be this:

11  1   13  57  
3   1   56  46  
4   2   5   40  
6   2   16  25  
19  2   25  12  
13  2   28  36  
16  3   17  13  
7   3   28  51  
5   3   34  15  
15  3   51  30  
17  3   56  40  
18  4   38  57  
2   4   41  55  
14  4   53  2   
1   4   56  17  
20  5   13  8   
8   5   14  58  
12  5   39  59  
10  5   41  33  
9   5   48  12  

Is there a simple way for doing this?
Remember that I’m new at Java.

regards,

Favolas

  • 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-05-26T17:55:33+00:00Added an answer on May 26, 2026 at 5:55 pm

    Simple use Comparator and use Arrays.sort(arr, comparator);

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

Sidebar

Related Questions

Continuing my quest of learning Java by doing a simple game, i stumbled upon
As I continue my quest of learning functional programming, I've come to wonder if
In my quest to learn C++, I have come across dynamic and static libraries.
In my quest to learn C I've come across a task which is causing
I am trying to use the jquery get statement: $.get(urlAddress+.asmx, { question: quest },
Hello gud fellas in my quest of learning spring, i created a web application
In my continuing quest to try and wrap my mind around RESTful-ness, I've come
I'm on a quest to see if I can figure out how to access
I my quest to develop a cross platform application I have decided to use
A bit of a silly question for more advanced programmers, but In my quest

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.