title: Sorting 2D array
body: <p>In 2D array sorting as i seen they just copied it to single dimension array and sorted it. But is there any other way to sort 2 dimensional array without using 1D array.</p>
  
  <p>// code</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;conio.h&gt;
  
  using namespace std;
  
  int main()
  {
  int rows, columns;
  int k = 0, temp;
  int rowColumn;
  
  //getting rows and columns number
  cout&lt;&lt;"Enter number of rows";
  cin&gt;&gt;rows;
  cout&lt;&lt;"Enter number of columns";
  cin&gt;&gt;columns;
  
  //declaring and intitalizing oneD and twoD array
  rowColumn = rows * columns;
  int arr[rows][columns];
  int oneDArr[rowColumn];
  
  //Fill 2D array by user
  cout&lt;&lt;"Fill 2D array row wise"&lt;&lt;endl;
  for(int i=0; i&lt;rows; i++)
  {
      for(int j=0; j&lt;columns; j++)
      {
          cin&gt;&gt;arr[i][j];
      }
  }
  
  //Taking 2d array in 1d array
  for(int i=0; i&lt;rows; i++)
  {
      for(int j=0; j&lt;columns; j++)
      {
          oneDArr[k] = arr[i][j];
          k++;
      }
  }
  
  //Bubble sort perform on 1d array
  for(int j=1;j&lt;rowColumn;j++)
  {
      for(int i=0; i&lt;rowColumn; i++)
      {
          if(oneDArr[i]&gt;oneDArr[i+1])
          {
              temp=oneDArr[i];
              oneDArr[i] = oneDArr[i+1];
              oneDArr[i+1]=temp;
          }
      }
  }
  
  //rearranging the oneD array to twoD array
  k = 0;
  for(int i=0; i&lt;rows; i++)
  {
      for(int j=0; j&lt;columns; j++)
      {
          arr[i][j] = oneDArr[k];
          k++;
      }
  }
  
  //Displaying sorted 2d Array
  for(int i=0; i&lt;rows; i++)
  {
      for(int j=0; j&lt;columns; j++)
      {
          cout&lt;&lt;arr[i][j]&lt;&lt;"\t";
      }
      cout&lt;&lt;"\n";
  } 
  } 
  </code></pre>
  
  <p>Is there any other way to sort 2D array with efficiency.  </p>