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

Filtering Visualforce List alphabetically.

In a standard salesforce pages there is a way to filter/Sort the list based on staring Letter. This is precisely the requirement which was required to be built for custom visualforce page. I built a page and class which would do this functionality


click here to check the visualforce page and the controller to built the list

You can do this by using Set

//Set have contains that will check for *

//then use logic to show them at the top or bottom of the list after sorting them

you can go for this post that sorts list using coparable interface

Another way to sort is adding 'Order by' in your query where you get your 'Contacts' from the database. If you say 'select id, name from Contact order by Name' and add the returned rows to a list and use that list in your page it will be ordered as you wanted.