Hello Robert
The order is indeed AD, Metric, and then prefix length. A router uses the AD and the metric to determine which route ends up being installed in the routing table. The prefix length is then used to determine which of the already installed routes in the routing table will be used to route a particular packet. AD and metric necessarily come before the prefix length. Consider this:
Administrative Distance - When a router learns about a specific route from two or more different sources, it must choose which source to use. This is done by looking at the AD value. The source with the lowest AD is installed in the routing table. All other sources never enter the routing table.
Metric - When a router learns about multiple routes to a specific destination from the same source (i.e. OSPF), it must decide which to install in the routing table. This is determined by the metric. The lower metric wins. If the metric is the same, then depending on the routing protocol used, equal cost load balancing is performed.
Prefix length - As stated in the lesson “Longest prefix match routing is an algorithm where the router prefers the longest prefix in the routing table. In other words, the most specific prefix.” But in order to choose the most specific prefix, the candidate prefixes must be in the routing table! And this is why AD and metric come first and second.
I hope this has been helpful!
Laz