I am trying to get all the fields in an object to comeup in a alphabetical order. i have tried using apex explorer to get the fields, though most of the fields come up in an order, there are few fields which do not come up in the right order.
Getting the field names in a particular order might not affect the code working, but as a part of standards used in our project, it is expected that we use them in alphabetical order.
Thanks Prady
This recipe will work:
I haven't tested this but it looks accurate.
You cannot rearrange fields in the output, their query parser just uses SOQL field list to filter its own master list of fields and you get response in whatever order their master list is.
I must admit though that this is the first time I hear of such coding standard, neither do I see any benefit from it... Just my 2 cents.
This can be done by going into the field then click 'reorder' and tick the checkbox for "Sort values alphabetically, not in the order entered. Values will be displayed alphabetically everywhere."
Why don't you just sort them yourself? List has a sort method, just pass in the list of string of your fields. See the method details here