We're using SOSL to search Account and Contact objects and facing an issue.
Records are returned in a variable of type List<List<sobject>>
say searchList
I'm using this variable(searchList), to find specifically just Account records using following code :
Account[] searchAccounts = (Account[])searchList[0];
for(Account a :searchAccounts ){
accountIdsIni.add(a.id);
}
System.debug('AccountIdsInitial='+accountIdsIni );
Now I print both searchList and searchAccounts variables. I'm finding Account records are returned in different order(sort) as shown below:
If you see, record(as highlighted in yellow) in debug log come first in SOSL variable but same record came on 4th number, when I separately printed the list of Accounts listed.
Please suggest if this is an expected behavior !!
accountIdsIni
?