I am trying to add values to a list iterating through a for loop like this.
List<String> leftvalues = new List<String>();
for(OpportunityLineItem o: OLI_List)
{
//Gets product name from map and adds to list
leftvalues.add(pbeId_PrNameMap.get(o.PricebookEntryId));
System.debug('*****Leftvalues:'+leftvalues);
}
Strangely its sorting internally after adding instead of adding at the end of list each time. What am i doing wrong .
Debug log results:
05:29:24.463 (463698000)|USER_DEBUG|[77]|DEBUG|***Leftvalues:{17TBUPGRADE}
05:29:24.464 (464053000)|USER_DEBUG|[77]|DEBUG|***Leftvalues:{17TBUPGRADE, 5UPB-C10/W}
05:29:24.464 (464397000)|USER_DEBUG|[77]|DEBUG|***Leftvalues:{17TBUPGRADE, 5UPB-C10/W, IFU-PN100M}
05:29:24.464 (464739000)|USER_DEBUG|[77]|DEBUG|***Leftvalues:{17TBUPGRADE, 5UPB-C10/W, CBK-UPG01, IFU-PN100M}
Why did new value CBK-UPG01 go to third position instead of fourth.?
How to prevent it from re positioning itself within the list ? Am i doing something wrong ?
o
value as well? I bet the issue is with the order ofOLI_List
.