How to sort two dimensional array in Java?
There is an overloaded sort method in java.util.Arrays class which takes two arguments: the array to sort and a java.util.Comparator object. 

You can add the following lines of code with your program to get the expected result.

import java.util.Arrays;
import java.util.Comparator;


Arrays.sort(testdatset, new Comparator&lt;double[]&gt;() {      
        @Override
        public int compare(double[] o1, double[] o2) {
            return Double.compare(o2[1], o1[1]);
        }
    });