Hey there! any question in your mind? Ask It Now!.

Popular Categories





How to use Bubble sort to sort an 2d Array?

–1 vote
582 views
asked in Programming by jatin Expert (3,823 points)
Here in the code ,I want column 1 in  ascending order, but not working . If you know how to use Bubble sort on 2D Array So please help me!
 
This is my code: 
 
String[][] 2dArray = new String[counter][2];
2dArray [counter][column1] = String.valueOf(counter);
2dArray [counter][column2] = "something something something";
for(int i = 0; i < 2dArray.length-1; i++){
     for(int j = i + 1; j > 0; j--){
       if(2dArray[i][j] < 2dArray[i-1][j]){ 
           int[][] temp = 2dArray[i-1][j];
           2dArray[i-1][j] = 2dArray[i][j];
           2dArray[i][j] = temp;                  
       }
     }
}

 

Please log in or register to answer this question.

Related Questions

+2 votes
1 answer 159 views
0 votes
0 answers 94 views
+2 votes
1 answer 1,036 views
–1 vote
0 answers 171 views
+1 vote
1 answer 209 views
+1 vote
1 answer 151 views
+1 vote
1 answer 955 views
+3 votes
1 answer 861 views
+2 votes
2 answers 829 views
+3 votes
1 answer 495 views

Not a Member yet?

Ask to Folks Login

My Account
456 Folks are online
0 members and 456 guest online
Your feedback is highly appreciated