+ Start a Discussion
Subha Ayyappan 7Subha Ayyappan 7 

How can I Order My List as the order of Another List?

Hi ,
I need  help in ordering the List. I have a List where the Field Priority__C must be ordered as Primary,Secondary, Tertiary,Fourth,Fifth,Sixth etc.. This order is in another List if Strings. 
The user can change the priority of the record, and after resequencing the priority the order must be same again as Primary, Secondary etc...
I tried ORDER BY Id. But when the priority is changed the Id remains same and so not able to get the ordering.
Please help.
Best Answer chosen by Subha Ayyappan 7
Jerun JoseJerun Jose
If you want to order the details using SOQL, I'd suggest create a formula field which returns an integer score for the priority, like 1 = Primary, 2 = Secondary, etc. You can then use this field in the ORDER BY clause in SOQL.

All Answers

Jerun JoseJerun Jose
If you want to order the details using SOQL, I'd suggest create a formula field which returns an integer score for the priority, like 1 = Primary, 2 = Secondary, etc. You can then use this field in the ORDER BY clause in SOQL.
This was selected as the best answer
Subha Ayyappan 7Subha Ayyappan 7
Thank you Jerun. It worked.