You need to sign in to do that
Don't have an account?

reiterating/looping a SelectOption in and comparing the order by a map
Hello,
I have a map with Name(String) and Ranks(Integer),
Name is the Pricebook name and Rank is Order by.
My usecase is that, the SelectOption should display the Name is the order defined in map.
How can i reiterate the SelectOption inorder to order it.
thank you for suggestion
I have a map with Name(String) and Ranks(Integer),
Name is the Pricebook name and Rank is Order by.
map<String,Integer> mapOfNameAndRank = new map<String,Integer>(); Name1, 1 Name2, 2 Name3, 3I am populating SelectOption in below manner:
public list<SelectOption> listOfOpt {get;set;} for(priceBook2 prc : [select id,Name from priceBook2 ){ listOfOpt.add(new SelectOption(prc.Id,prc.Name)); }
My usecase is that, the SelectOption should display the Name is the order defined in map.
How can i reiterate the SelectOption inorder to order it.
thank you for suggestion
Try like below:
Thanks,
Maharajan.C
All Answers
What order do you get if you sort using the list.sort method )The List.sort method sorts SelectOption elements in ascending order using the value and label fields, and is based on comparison sequence)
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_collections_lists_sorting.htm
Or you can try using ORDER BY directly in your SOQL query. I ran the below example in my local org and it give me results in alphabetical order
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_orderby.htm
Anudeep
Try like below:
Thanks,
Maharajan.C
love status (https://fevers.website/category/love-whatsapp-status-video/)