public static int[] sortValues(Matrix m){
  double[] v=new double[m.getColumnDimension()];
  int[] index=new int[v.length];
  for (int i=0; i < v.length; i++) {
    v[i]=m.get(i,i);
    index[i]=i;
  }
  for (int i=0; i < v.length; i++) {
    for (int j=i + 1; j < v.length; j++) {
      if (Math.abs(v[i]) < Math.abs(v[j])) {
        double tmpValue=v[j];
        v[j]=v[i];
        v[i]=tmpValue;
        int tmpIndex=index[j];
        index[j]=index[i];
        index[i]=tmpIndex;
      }
    }
  }
  return index;
}

public static int [ ] sortValues ( Matrix m ) { double [ ] v = new double [ m . getColumnDimension ( ) ] ; int [ ] index = new int [ v . length ] ; for ( int i = 0 ; i < v . length ; i ++ ) { v [ i ] = m . get ( i , i ) ; index [ i ] = i ; } for ( int i = 0 ; i < v . length ; i ++ ) { for ( int j = i + 1 ; j < v . length ; j ++ ) { if ( Math . abs ( v [ i ] ) < Math . abs ( v [ j ] ) ) { double tmpValue = v [ j ] ; v [ j ] = v [ i ] ; v [ i ] = tmpValue ; int tmpIndex = index [ j ] ; index [ j ] = index [ i ] ; index [ i ] = tmpIndex ; } } } return index ; }
sort indices by values
