code: public static void descendingOrder(DMatrixRMaj U , boolean tranU ,
                                         double singularValues[] ,
                                         int singularLength ,
                                         DMatrixRMaj V , boolean tranV )
      {
  //        checkSvdMatrixSize(U, tranU, W, V, tranV);
  
          for( int i = 0; i < singularLength; i++ ) {
              double bigValue=-1;
              int bigIndex=-1;
  
              // find the smallest singular value in the submatrix
              for( int j = i; j < singularLength; j++ ) {
                  double v = singularValues[j];
  
                  if( v > bigValue ) {
                      bigValue = v;
                      bigIndex = j;
                  }
              }
  
              // only swap if the current index is not the smallest
              if( bigIndex == i)
                  continue;
  
              if( bigIndex == -1 ) {
                  // there is at least one uncountable singular value.  just stop here
                  break;
              }
  
              double tmp = singularValues[i];
              singularValues[i] = bigValue;
              singularValues[bigIndex] = tmp;
  
              if( V != null ) {
                  swapRowOrCol(V, tranV, i, bigIndex);
              }
  
              if( U != null ) {
                  swapRowOrCol(U, tranU, i, bigIndex);
              }
          }
      }
docs: <p>
  Similar to {@link #descendingOrder(DMatrixRMaj, boolean, DMatrixRMaj, DMatrixRMaj, boolean)}
  but takes in an array of singular values instead.
  </p>
  
  @param U Matrix. Modified.
  @param tranU is U transposed or not.
  @param singularValues Array of singular values. Modified.
  @param singularLength Number of elements in singularValues array
  @param V Matrix. Modified.
  @param tranV is V transposed or not.