const swap = ( array, index1, index2 ) => {

    // store a tmp variable at pos index2
    const tmp = array[index2];