Consider `ContactJoinTest::testCreateWithPrimaryAndBilling` which writes the value:
'address_billing.state_province_id:abbr' => 'AK',
The symbol 'AK' can map to three places: Akwa Ibom (Nigeria), Atakora
(Benin), and Alaska (USA). This is an ambiguous choice. It should be
resolved in a consistent way.
One flavor of ambiguity comes from MySQL. When loading abbreviations, Civi
queries with `ORDER BY abbreviation`. This is a *typically* stable, but it
has no *guaranteed* resolution. Adding a secondary sort key makes the
outcome clear/unambiguous.
$from = 'FROM %3';
$wheres = [];
$order = 'ORDER BY %2';
+ if (in_array('id', $availableFields, TRUE)) {
+ // Example: 'ORDER BY abbreviation, id' because `abbreviation`s are not unique.
+ $order .= ', id';
+ }
// Use machine name in certain contexts
if ($context === 'validate' || $context === 'match') {