+ 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.