For each "ordered" should give you what you need.
Just use the y value. It will parse ascending, descending, based on that value, and the index, low to high for any of the same value.
Not 100% on that last part, but that's the usual order of operations, and the chances of exact same y are pretty low when using subpixel.