I was looking into this and I don't know if it's actually broken... It looks correct code wise and there's some additional sorting based off the availability of the station. Can you provide a simple save file reproducing the issue so I can test?
If you want to get ahold of me I'm almost always on Discord.
Ok, the issue was in the stations listing not using the right sort order. The train stops list was using the right sort order. It's now fixed for the next release.
If you want to get ahold of me I'm almost always on Discord.