MemberSeptember 22, 2018 at 5:25 am
Adding some points and code snippet:
Apex provides a sort method on the List class for sorting. For objects such as this however, you must implement the Comparable interface. Note the Salesforce doc samples indicate you need to make your class 'global' scope, this is no longer true.
public class jobsWrapper implements Comparable
public Integer compareTo(Object compareTo)
jobsWrapper jobsWrapper = (jobsWrapper) compareTo;
if (job.Name == jobsWrapper.job.Name) return 0;
if (job.Name > jobsWrapper.job.Name) return 1;
Then once you put your objects into a list you can use the sort method.
List<jobsWrapper> jobs = new List<jobsWrapper>();
// Add things to the list ...