quickSort and binarySearch algorithms in JavaScript