I'll take a closer look at this trac ticket, but from what i read there, the issue seems the other way around from what I report.
In my case the rate engine chose the shorter prefix with the lower cost from card A, but the longer prefix with higher cost from card B is the correct destination.
Added after 28 minutes: I can confirm that the patch here
http://www.asterisk2billing.org/cgi-bin ... ticket/209
does not fix this particular problem. It is a solution for exactly the opposite situation. I don't know why somebody would like to match the shorter prefix.
The longer the prefix the more specific. This way if one has a longer prefix only in one of the ratecards, although with a higher rate, rate engine should match the longer one.