Hello Roi
Well, not quite. There are two processes that you are referring to. The first has to do with how the routing table is populated. In other words, the process and the rules by which routes are either installed or not installed in the routing table. For this process, the AD and Metric play a role. For more details on how the routing table is populated, take a look at this NetworkLessons note.
The other process is how route entries are matched. In other words, when you have a packet that you want to route, you must look at its destination IP address and match it with one of the entries in the routing table. This process involves things like the longest prefix match. For more details on matching entries in the routing table, take a look at this NetworkLessons note.
I hope this has been helpful!
Laz