You need to sign in to do that
Don't have an account?
Vivek Viswanath
How to sort the list returned from a map?
I am calling this function that returns a list from a map I want to sort this list the query itself has an orderby but its lost when we do the .values() I checked and the query works fine.
return getOriginalOrderItems( programOrderIds ).values();
Suppose I want to sort on HS_Level_Display__c
can do something like this.
list<HS_Order_Items__c> items = new list<HS_Order_Items__c>();
items = getOriginalOrderItems( programOrderIds ).values();
items.sort(HS_Level_Display__c);
Message Edited by Vivek Viswanath on 09-08-2008 07:44 AM
return getOriginalOrderItems( programOrderIds ).values();
Suppose I want to sort on HS_Level_Display__c
can do something like this.
list<HS_Order_Items__c> items = new list<HS_Order_Items__c>();
items = getOriginalOrderItems( programOrderIds ).values();
items.sort(HS_Level_Display__c);
Message Edited by Vivek Viswanath on 09-08-2008 07:44 AM
from apex docs:
Sorts the items in the list in ascending order. You can
only use this method with lists composed of primitive
sort Void
data types. In the following example, the list has three
elements.When the list is sorted, the first element is
null because it has no value assigned while the second
element has the value of 5:
List L1 = new Integer[3];
// Assign values to the first
// two elements
L1[0] = 10;
L1[1] = 5;
L1.sort();
// First element is null, second is 5
system.assertEquals(L1.get(1), 5);
You will need to build your own method for sorting your list of custom SObjects.