-
Notifications
You must be signed in to change notification settings - Fork 10
Salesforce APEX API to Sort Array/List of SelectOption instances
abhinavguptas/Apex-Select-Option-Sorting
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This repository provides a Utility class to provide efficient sorting of Apex SelectOption instances. Efficient as all the heavy lifting of sorting is internally handled by native List.sort(), so this leads to fast sorting and lesser consumption of script statements and one is more safe from Governor. Example Usage ============= Sort by Label : ---------------- Selectoption[] opts = new Selectoption[] { new Selectoption('v8', 'l8'), new Selectoption('v1', 'l1'), new Selectoption('v5', 'l5') }; SelectOptionSorter.doSort(opts, SelectOptionSorter.FieldToSort.Label); // This will print the sorted list System.debug (' Sorted Options : ' + opts); // // Following will be output on console // |DEBUG| Sorted Options : (System.SelectOption[value="l1", label="v1", disabled="false"], System.SelectOption[value="l5", label="v5", disabled="false"], System.SelectOption[value="l8", label="v8", disabled="false"]) Sort by Value : ----------------- // Just pass SelectOptionSorter.FieldToSort as "SelectOptionSorter.FieldToSort.Value" // instead of "SelectOptionSorter.FieldToSort.Label" SelectOptionSorter.doSort(opts, SelectOptionSorter.FieldToSort.Value);
About
Salesforce APEX API to Sort Array/List of SelectOption instances
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published