Refactor bestDistance and bestResults array sorting