swap = (leftIndex, rightIndex) => {
        const temp = array[leftIndex];
        array[leftIndex] = array[rightIndex];
        array[rightIndex] = temp;
      }
Swaps two elements in array.
@param {number} leftIndex
@param {number} rightIndex