Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
function generateRandomInteger (max = Number.MAX_SAFE_INTEGER, min = 0) {
max = Math.floor(max)
- if (min) {
+ if (min != null || min !== 0) {
min = Math.ceil(min)
return Math.floor(Math.random() * (max - min + 1)) + min
}
}
const randomPivotIndexSelect = (leftIndex, rightIndex) => {
- return generateRandomInteger(leftIndex, rightIndex)
+ return generateRandomInteger(rightIndex, leftIndex)
}
function swap (array, index1, index2) {
static generateRandomInteger (max = Number.MAX_SAFE_INTEGER, min = 0) {
max = Math.floor(max)
- if (min) {
+ if (min != null || min !== 0) {
min = Math.ceil(min)
return Math.floor(Math.random() * (max - min + 1)) + min
}