Salesforce Summer 15 New Feature || Predictable Iteration Order for Apex Unordered Collections

by Sudipta Deb | Apr 27, 2015 | Apex, Salesforce, Salesforce Release, Summer15 | 0 comments

After Summer15 Salesforce release, the order of elements in unordered elements (Map and Set) is always the same. Previously the order was arbitrary and as a developer, you have no control on the order.

Now as you can see, with this new feature, we are trying to order the unordered elements. A little strange to me. But if you have some code snippet, where the logic depends on the ordering of the elements, then this new feature will be really helpful.

Let’s consider the below code snippet –

If you run this code after Summer15, you will get the elements in the same order every time you execute.

21:01:19.145 (145215707)|USER_DEBUG|[10]|DEBUG|Index: 1 Employee: James
21:01:19.145 (145338304)|USER_DEBUG|[10]|DEBUG|Index: 2 Employee: Sudipta
21:01:19.145 (145498650)|USER_DEBUG|[10]|DEBUG|Index: 3 Employee: Christiaan
21:01:19.145 (145587990)|USER_DEBUG|[10]|DEBUG|Index: 4 Employee: Victor

So now your Unordered Collections are also predictable.

Written by

Related Posts

Salesforce Cancels the “Permissions in Profiles” Retirement: What It Means for Admins and Architects

Salesforce Cancels the “Permissions in Profiles” Retirement: What It Means for Admins and Architects

For the last few years, Salesforce administrators, architects, and security teams have been preparing for a major platform change: the retirement of permissions managed directly through Profiles. Salesforce had previously announced plans to move organizations toward a Permission Set–led security model, with enforcement expected to begin around the Spring ’26 timeframe.

read more...

0 Comments

Leave a Reply