index.js
function multiSelect(arr, left, right, n, compare) {
    var stack = [left, right],
        mid;

    while (stack.length) {
        right = stack.pop();
        left = stack.pop();

        if (right - left <= n) continue;

        mid = left + Math.ceil((right - left) / n / 2) * n;
        quickselect(arr, mid, left, right, compare);

        stack.push(left, mid, mid, right);
    }
}
function multiSelect(arr, left, right, n, compare) {
    var stack = [left, right],
        mid;

    while (stack.length) {
        right = stack.pop();
        left = stack.pop();

        if (right - left <= n) continue;

        mid = left + Math.ceil((right - left) / n / 2) * n;
        quickselect(arr, mid, left, right, compare);

        stack.push(left, mid, mid, right);
    }
}
function multiSelect ( arr , left , right , n , compare ) { var stack = [ left , right ] , mid ; while ( stack . length ) { right = stack . pop ( ) ; left = stack . pop ( ) ; if ( right - left <= n ) continue ; mid = left + Math . ceil ( ( right - left ) / n / 2 ) * n ; quickselect ( arr , mid , left , right , compare ) ; stack . push ( left , mid , mid , right ) ; } }
sort an array so that items come in groups of n unsorted items, with groups sorted between each other; combines selection algorithm with binary divide & conquer approach
sort an array so that items come in groups of n unsorted items with groups sorted between each other ; combines selection algorithm with binary divide & conquer approach