You need to sign in to do that
Don't have an account?
Custom Sort Wrapper Class
I created a wrapper class that implements the Comparable interface. However, when I sort the list of wrapper, the list is still sorting by the name
public with sharing class SampleSort implements Comparable{ private Goal__c goalRecord; public CaseSLAWrapperClass(Goals__c s) { goalRecord = s; } public Integer compareTo(Object compareTo) { SampleSort compareToGoal = (SampleSort)compareTo; if(goalRecord.Display_Order__c < compareToGoal.goalRecord.Display_Order__c) return 1; else if (goalRecord.Display_Order__c < compareToGoal.goalRecord.Display_Order__c) return -1; else return 0; } }
Instances of CaseSLAWrapperClass should be ordered perhaps?
Regards
Alain
Please follow the below link for better understading of comparable interface.
http://www.infallibletechie.com/2013/08/comparable-interface-in-salesforce.html
Check below post for more information
1) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_comparable.htm