Add column in stops table to order stops

New stop_order column allows the stops for each direction to be sorted
in the order they are located on the line. Also moved writing to the
stops table to its own function.