Sorting a 2d array by column : <p>Here is my code, im kinda lost as to how to make this work the way i want to, i have made it so the user will enter a 3x3 2d array, im trying to sort each column but im having a hard time figuring it out and then printing the array while still keeping the original in tack....</p>

<pre><code>package newproject;

import java.util.Scanner;


public class ColumnSorting {
public static void main(String [] args){
    double a[][]=new double[3][3];
    Scanner input = new Scanner(System.in);

    for(int row=0;row&lt;3;row++){

        for(int col=0;col&lt;3;col++){
            System.out.println("Enter value: ");
            a[row][col]=input.nextDouble();
        }
    }
    displayArray(a);

}
public static void  displayArray(double x[][])    {
for (int row=0;row&lt;x.length;row++) {
  for(int column = 0;column&lt;x[row].length; column++) {
       System.out.print(x[row][column]+"\t");
 }
 System.out.println();
}
   }
       public static double[][] sortColumns(double[][] m){
         java.util.Arrays.sort(m, new java.util.Comparator&lt;double[]&gt;() {
             public int compare(double[] a, double[] b) {
               return Double.compare(a[0], b[0]);
    }
 });
}






}
</code></pre>
