Applies this permutation in-place to the elements of an integer array
336737
public void permute(final int[] arr) {
    checkArgument(arr.length == sources.length);
    final int[] tmp = new int[arr.length];
    for (int i = 0; i < tmp.length; ++i) {
      tmp[i] = arr[sources[i]];
    }
    System.arraycopy(tmp, 0, arr, 0, arr.length);
  }
9691
function reverseArray(array) {
  let index = array.length,
      newArray = [];

  while (index--) {
    newArray.push(array[index]);
  }

  return newArray;
}
714194
public static void shuffle(long[] longArray) {
		int swapPlace = -1;

		for(int i = 0; i < longArray.length; i++) {
			swapPlace = (int) (Math.random() * (longArray.length - 1 ));
			XORSwap.swap(longArray, i, swapPlace);
		}
	}
613459
private int permutationParity(int[] vs) {
        int n = 0;
        for (int i = 0; i < vs.length; i++)
            for (int j = i + 1; j < vs.length; j++)
                if (vs[i] > vs[j]) n++;
        return (n & 0x1) == 1 ? -1 : 1;
    }
748032
@Deprecated
  public static void permute(final int[] arr, final int[] permutation) {
    checkArgument(arr.length == permutation.length);
    final int[] tmp = new int[arr.length];
    for (int i = 0; i < tmp.length; ++i) {
      tmp[i] = arr[permutation[i]];
    }
    System.arraycopy(tmp, 0, arr, 0, arr.length);
  }
1325059
function( array ){
	var i = array.length, j, swap;
	while( i ){
		j = Math.floor( Math.random() * i-- );
		swap = array[i];
		array[i] = array[j];
		array[j] = swap;
	}
	return array;
}
444663
private void swap(int i, int j) {
        int t = pq[i];
        pq[i] = pq[j];
        pq[j] = t;
        qp[pq[i]] = i;
        qp[pq[j]] = j;
    }
634154
public static <T> void shuffleArray(T[] arr) {
		for (int i = arr.length; i > 1; i--)
			swap(arr, i - 1, rand.nextInt(i));
	}
662603
function() {
    var M = this.dup(), els;
    var n = this.elements.length, k = n, i, np, kp = this.elements[0].length, p;
    do { i = k - n;
      if (M.elements[i][i] == 0) {
        for (j = i + 1; j < k; j++) {
          if (M.elements[j][i] != 0) {
            els = []; np = kp;
            do { p = kp - np;
              els.push(M.elements[i][p] + M.elements[j][p]);
            } while (--np);
            M.elements[i] = els;
            break;
          }
        }
      }
      if (M.elements[i][i] != 0) {
        for (j = i + 1; j < k; j++) {
          var multiplier = M.elements[j][i] / M.elements[i][i];
          els = []; np = kp;
          do { p = kp - np;
            // Elements with column numbers up to an including the number
            // of the row that we're subtracting can safely be set straight to
            // zero, since that's the point of this routine and it avoids having
            // to loop over and correct rounding errors later
            els.push(p <= i ? 0 : M.elements[j][p] - M.elements[i][p] * multiplier);
          } while (--np);
          M.elements[j] = els;
        }
      }
    } while (--n);
    return M;
  }
374699
public void setTo(Permutation other) {

        if (this.values.length != other.values.length)
            throw new IllegalArgumentException("permutations are different size");

        for (int i = 0; i < this.values.length; i++) {
            this.values[i] = other.values[i];
        }
    }
57223
private void swap(int n, int m) {
		int eM = elements[m];
		int eN = elements[n];
		elements[m] = eN;
		elements[n] = eM;
		positions[eM] = n;
		positions[eN] = m;
	}
668267
public static int[] swap(int[] array, int index1, int index2) {
		if (isEmpty(array)) {
			throw new IllegalArgumentException("Number array must not empty !");
		}
		int tmp = array[index1];
		array[index1] = array[index2];
		array[index2] = tmp;
		return array;
	}
1361447
public static void shuffle(short[] shortArray) {
		int swapPlace = -1;

		for(int i = 0; i < shortArray.length; i++) {
			swapPlace = (int) (Math.random() * (shortArray.length - 1 ));
			XORSwap.swap(shortArray, i, swapPlace);
		}
	}
52195
function indexOfElementInArray(element, array) {
  if (!array) return -1;

  if (array.indexOf) {
    return array.indexOf(element);
  }

  var len = array.length,
    i;

  for (i = 0; i < len; i += 1) {
    if (array[i] === element) {
      return i;
    }
  }

  return -1;
}
455008
public static void shuffle(long[] array) {
        for (int i = array.length - 1; i > 0; i--) {
            int j = Prng.nextInt(i + 1);
            // Swap array[i] and array[j]
            long tmp = array[i];
            array[i] = array[j];
            array[j] = tmp;
        }
    }
1073464
public static void sortArray(int[] array) {

        boolean swapped;

        do {
            swapped = false;

            for (int i = 0; i < array.length - 1; i++) {
                if (array[i] > array[i + 1]) {
                    int temp = array[i + 1];

                    array[i + 1] = array[i];
                    array[i]     = temp;
                    swapped      = true;
                }
            }
        } while (swapped);
    }
664698
private void moveAtFirst(int n_from) {
		int eT = elements[0];
		int eF = elements[n_from];
		positions[eT] = -1;
		positions[eF] = 0;
		elements[0] = eF;
		elements[n_from] = -1;
	}