code: protected static void sort(double[] d, double[] e, DenseMatrix V) {
          int i = 0;
          int n = d.length;
          double[] temp = new double[n];
          for (int j = 1; j < n; j++) {
              double real = d[j];
              double img = e[j];
              for (int k = 0; k < n; k++) {
                  temp[k] = V.get(k, j);
              }
              for (i = j - 1; i >= 0; i--) {
                  if (d[i] >= d[j]) {
                      break;
                  }
                  d[i + 1] = d[i];
                  e[i + 1] = e[i];
                  for (int k = 0; k < n; k++) {
                      V.set(k, i + 1, V.get(k, i));
                  }
              }
              d[i + 1] = real;
              e[i + 1] = img;
              for (int k = 0; k < n; k++) {
                  V.set(k, i + 1, temp[k]);
              }
          }
      }
docs: Sort eigenvalues and eigenvectors.