If you run plot(x,y) instead of plot(x,y,'o'), you will see the correct curve. So your data is already "sorted" as you wanted. I would say that you are lucky that the x, y data is in current order. If x is sorted based on its value, it would be hard to get to the current order.
To illustrate the issue