function swap(array, i, j) {
    var temp = array[i];
    array[i] = array[j];
    array[j] = temp;
  }
Swaps the elements at two specified positions of an array.

@private
@param {Array} array
@param {number} i
@param {number} j

@examples
var array = [1, 2, 3, 4, 5];

swap(array, 2, 3) // array == [1, 2, 4, 3, 5]