I want to get the picklist values of a picklist field in Apex.

I use the someFieldResult.getPicklistValues(); function and that works fine. This gives me all the picklist values, in alphabetic order (e.g. Alpha, Beta, Gamma).

However, I want to have those values in the order they were entered (e.g. Gamma, Alpha, Beta). How to do that?

1 Answer 1


The DescribeFieldResult.getPickListValues method returns the values in their currently defined order. If you sort then after you have entered them by e.g. checking the:

Sort values alphabetically, not in the order entered. Values will be displayed alphabetically everywhere.

checkbox then that sorted order will be the only one available to you from the platform.

But you can go back and manually reorder the values. I suggest you do that via the "Reorder" button displayed for the "Picklist Values" of a picklist field.

  • Now that I debug the list, yes, this seems to be the case. I was confused because the order is again messed up when I show the List of options in Visualforce: they always show in alphabetic order. Is there something I can do about that? May 18, 2015 at 6:26
  • 2
    Oh well, nevermind. I used a map, and that never works for sorting. Now I use the original List and all is fine! Thanks. May 18, 2015 at 6:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .