res_pjsip.so has configuration option i.e. "endpoint_identifier_order" to determine how res_pjsip will match the incoming SIP request against present endpoints.
This order configuration is useful in PJSIP scenario where we have PJSIP extensions and trunks are coming from the same IP.
SipSetting module(v18.104.22.168+ Or v22.214.171.124+) FreePBX GUI has an option to configure the endpoint identification order.
FreePBX->Settings -> asterisk SIP settings ->Chan PJSIP settings
Drag and drop the blocks to decides the priorities.