Correct issue with algorithm determination issue
Fix a bug in sorting algorithm mixing x and y