Whenever I try to parse some JSON data for arrival predicitions via a URL, the timeToStation field always appears in a random order rather than chronologically with the nearest train first. Does anyone know why this is happening?
Looking at the output, it appears to be in Vehicle ID order rather than order of arrival. I have no idea whether this refers to the train itself or to the “running number” it is given each day.
London Vehicle Finder offers the option to support by vehicle ID (which in that case definitely relates to the bus itself) or where they are on the route so I guess they are applying the necessary technique to get whichever is not the default.
To be fair, there isn’t any documentation to suggest that the output should come in any particular order. With APIs, it’s up the the programmer to sort the output for display/storage.