The order
- Into the table: for each prefix, lowest administrative distance wins.
- Same AD (same protocol): lowest metric wins. A tie on both: all of them, load-shared.
- Out the door: for each packet, the longest matching prefix in the table wins.
- Nothing matches and no default route: dropped.
AD and metric only compare routes to the exact same prefix. A /24 and a /22 are different routes and both go in.