function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MXMX 

Sorting a SelectList

Hey there,

 

is there a easy way to sort a SelectList alphabetic in Visualforce? Like sortby ="abc" or something like that, or have I got to do this in my controller?

 

Thanks a lot,

MX

Best Answer chosen by Admin (Salesforce Developers) 
MXMX

Found the solution by myself. You can just use the sort() method in your controller on the list after adding options.

 

For example

 

mylist.add('c');

mylist.add('f');

mylist.add('a');

mylist.sort();