You need to sign in to do that
Don't have an account?
kamal3883
Sorting in map
HI all,
I want to do sorting of map based on value. here is code:
for (Pricebook2 pb : [select id, Name from Pricebook2 where id in :ids order by name])
{
myPBNames.put(pb.id, pb.name);
}
Results are got sorted based on id. But i want this should be based on name.
Even Order by is not working. Please suggest.
Check this
http://boards.developerforce.com/t5/Apex-Code-Development/Sorting-a-Map-by-Value/td-p/297945
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
i checked this one. But didnt get proper solution. Is it possible to use order by in query so that results are sorted.
Yes, but you are telling that the previous code is not ordering by name.
Check this if it helps
http://sforcetips.blogspot.in/2013/05/apex-map-sorting.html
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
when i check values of map by accmap.get(key). it shows sorted values but when i try to print accmap. Order is still same.
same issue: map shows values in same order.
All values are unique so no issue with that. I tried this portion of code. when i print simply values of map it shows sorted values. But when i try to print full maporder is still.
Is there some other way that i can sort it in java script. Please provide some code
My original map is MyPBNames
Are you able to get a workaround for this Map<id,Name>.
I need same issue solution I want to sort by Name. Please post me the solution if you have anything.
Thank you,
Aruna.