title: Bubble-Sort 2D array
body: <p>I need to build a code that bubble sort 2D array. The trick here is that I cannot use an one dimensional array helper, or move the items to another array.</p>
  
  <p>The sorting need to be on the 2D array.</p>
  
  <p>Now I built my function. But something is going wrong. This is my output</p>
  
  <pre><code>1      1      2      6     12     32
   49     44     54     55    100    344
  </code></pre>
  
  <p>is to close to be done, and I cant think how to do it. </p>
  
  <pre><code> public static int [] [] sortMatrix(int[][]matrix){
      for(int x = matrix.length  ; x &gt;0  ; x-- ){
          for(int i = matrix[0].length  ; i &gt; 0 ; i-- ){
              for(int j = 0 ; j &lt; x  ; j++){
                  for(int t = 0 ;t &lt; i    ;  t++){
                      if(t &lt; matrix[0].length - 1 &amp;&amp; matrix[j][t] &gt; matrix[j][t+1] ){
                          swap(matrix , j , t, t+1);
                      }
                      else if(t == matrix[0].length - 1 &amp;&amp; j != matrix.length -1&amp;&amp; matrix[j][t] &gt; matrix[j+1][0] ){
                          swap1(matrix ,j , t , j + 1);
                      }                       
                  }
              }               
          }           
      }
  </code></pre>