public static int[] randomPermutation(final int[] out,Random random){
  for (int i=out.length - 1; i > 0; i--) {
    int ri=random.nextInt(i + 1);
    int tmp=out[ri];
    out[ri]=out[i];
    out[i]=tmp;
  }
  return out;
}

public static int [ ] randomPermutation ( final int [ ] out , Random random ) { for ( int i = out . length - 1 ; i > 0 ; i -- ) { int ri = random . nextInt ( i + 1 ) ; int tmp = out [ ri ] ; out [ ri ] = out [ i ] ; out [ i ] = tmp ; } return out ; }
perform a random permutation of the array , in - place . knuth / fisher - yates style shuffle
