function swap(array, index1, index2) {
  [array[index1], array[index2]] = [array[index2], array[index1]];
}
swap in-place between two elements in an array
@param {Array} array array to operate on
@param {Number} index1
@param {Number} index2