2 件の回答
I ended up creating a bubble sort method to sort my list. Thanks for your help anyways, Thermo.Below is my code:// Sort Activities by ActivityDate. This is a bubble sort algorithm. public void sortActivitiesByActivityDate() { Integer n = ActivityList.size(); // Create a temporary variable to hold a bubble sort temp. The sObject type has to exist in your generic sObject lists. In my case, I have Task // and Event sObjects in my list and I can use either "new Task() or new Event()". sObject temp = new Task(); for (Integer i = 0; i < n; i++) { for (Integer j = 1; j < (n-i); j++) { // Sort by Descending order by ActivityDate. To sort by ascending order, change "<" to ">" in the line below. if ((Date)ActivityList[j-1].get('ActivityDate') < (Date)ActivityList[j].get('ActivityDate')) { temp = ActivityList[j-1]; ActivityList[j-1] = ActivityList[j]; ActivityList[j] = temp; } } } }