title: How to sort a 2D array row and column wise?
body: <p>I want to sort a 2-dimensional array both row and column wise. I'm able to sort it row wise but however I'm not able to do it column wise. I'm trying to do it the following code:<br></p>
  
  <pre><code>#include&lt;stdio.h&gt;
  void sort_rows(int *arr,int n)
  {
      int i;
      for(i=1;i&lt;n;i++)
      {
         int key=arr[i];
         int j=i-1;
         while(j&gt;=0 &amp;&amp; key&lt;arr[j])
         {
             arr[j+1]=arr[j];
             j--;
         }
          arr[j+1]=key;
      }
  }
  void sort_column(int arr[][3],int size)
  {
      int i,j;
      int key,k;
      for(i=0;i&lt;size;i++)
      {
          for(j=1;j&lt;size;j++)
          {
              key=arr[j][i];
              k=j-1;
              while(k&gt;=0 &amp;&amp; arr[k][i]&gt;key)
              {
                  arr[k+1][i]=arr[k][i];
                  k--;
              }
              arr[k+1][i]=key;
          }
      }
  }
  int main()
  {
      int arr[][3]={{9,8,7},{6,5,4},{3,2,1}};
      int i,j,size;
      size=((sizeof(arr)/sizeof(arr[0][0])/(sizeof(arr[0])/sizeof(arr[0][0])))); //calculates the size of each row.
      for(i=0;i&lt;size;i++)
      {
          sort_rows(arr[i],sizeof(arr[i])/sizeof(arr[i][0]));
      }
      size=sizeof(arr)/sizeof(arr[0]); //calculates the size of each column.
      for(i=0;i&lt;size;i++)
      {
          sort_column(arr[i][size],size);
      }
      return 0;
  }
  </code></pre>
  
  <p>I used selection sort to sort rows and column. I know that my approach to sort it column wise is wrong. I'm getting this error in my code: <code>passing argument 1 of 'sort_column' makes pointer from integer without a cast [enabled by default]</code>
  Please help me correcting this code.</p>