Given the air-routes graph, say I want to get all possible one-stopover routes, like so:
[home] --distance--> [stopover] --distance--> [destination]
where [home], [stopover] and [destination] are airport nodes that each have a property 'code' that represent an airport code; and distance is an integer weight given to each edge connecting two airport nodes.
How could I write a query that gets me the airport codes for [home], [stopover] and [destination] such that the results are sorted as follows:
- [home] airport codes are sorted alphabetically.
- For each group of [home] airport, the [stopover] airport codes are sorted by the distance between [home] and [stopover] (ascending).
- After sorting 1 and 2, [destination] airport codes are sorted by the distance between [stopover] and [destination].
(Note: it doesn't matter if [home] and [destination] are the same airport)