diff --git a/app/Ninja/Repositories/VendorRepository.php b/app/Ninja/Repositories/VendorRepository.php index e0729a8f7a09..232a66cdfdda 100644 --- a/app/Ninja/Repositories/VendorRepository.php +++ b/app/Ninja/Repositories/VendorRepository.php @@ -95,6 +95,15 @@ class VendorRepository extends BaseRepository $vendorcontactIds = []; + // If the primary is set ensure it's listed first + usort($vendorcontacts, function ($left, $right) { + if (isset($right['is_primary']) && isset($left['is_primary'])) { + return $right['is_primary'] - $left['is_primary']; + } else { + return 0; + } + }); + foreach ($vendorcontacts as $vendorcontact) { $vendorcontact = $vendor->addVendorContact($vendorcontact, $first); $vendorcontactIds[] = $vendorcontact->public_id;