async function mattSort(numArr, visuals, option) {
    for (let i = 0; i < numArr.length;) {
        if (option.val === 'stop') break;
        if (numArr[i] > numArr[i + 1]) {
            let x = numArr[i];
            numArr[i] = numArr[i + 1];
            numArr[i + 1] = x;
            // animate just the swaps when array size is large
            if (numArr.length >= 200){
                // waits for a returned promise, which is a timeout for the set time variable
                await iterationUpdate(visuals, i, option);
            }
            i = -1;
        }
        i++;
        // animate minor details when array is small. Don't do so when array is larger, just animate swaps for performance
        if (numArr.length < 200){
            // waits for a returned promise, which is a timeout for the set time variable
            await iterationUpdate(visuals, i, option);
        }
    }
    // return a promise for canvas to use
    return new Promise((resolve, reject) => {resolve()});
}
// must be async so it can pause execution on the set interval in iterationUpdates returned promise
must be async so it can pause execution on the set interval in iterationUpdates returned promise
must be async so it can pause execution on the set interval in iterationUpdates returned promise
async function mattSort(numArr, visuals, option) {
    for (let i = 0; i < numArr.length;) {
        if (option.val === 'stop') break;
        if (numArr[i] > numArr[i + 1]) {
            let x = numArr[i];
            numArr[i] = numArr[i + 1];
            numArr[i + 1] = x;
            if (numArr.length >= 200){
                await iterationUpdate(visuals, i, option);
            }
            i = -1;
        }
        i++;
        if (numArr.length < 200){
            await iterationUpdate(visuals, i, option);
        }
    }
    return new Promise((resolve, reject) => {resolve()});
}
async function mattSort ( numArr , visuals , option ) { for ( let i = 0 ; i < numArr . length ; ) { if ( option . val === 'stop' ) break ; if ( numArr [ i ] > numArr [ i + 1 ] ) { let x = numArr [ i ] ; numArr [ i ] = numArr [ i + 1 ] ; numArr [ i + 1 ] = x ; if ( numArr . length >= 200 ) { await iterationUpdate ( visuals , i , option ) ; } i = - 1 ; } i ++ ; if ( numArr . length < 200 ) { await iterationUpdate ( visuals , i , option ) ; } } return new Promise ( ( resolve , reject ) => { resolve ( ) } ) ; }
must be async so it can pause execution on the set interval in iterationUpdates returned promise
must be async so it can pause execution on the set interval in iterationUpdates returned promise
// animate just the swaps when array size is large // waits for a returned promise, which is a timeout for the set time variable // animate minor details when array is small. Don't do so when array is larger, just animate swaps for performance // waits for a returned promise, which is a timeout for the set time variable // return a promise for canvas to use