fixing sort logic

The existing logic for sorting the routes was slightly flawed, which in some cases would cause the routes to be listed out of (alphabetical) order.