changed name of doRecursion to compareAndSort