title: How to sort list items for Date field value (Apex, Salesforce)
body: <p>With Salesforce's Apex, is there any way to sort list items, for Date field value. Please refer the TODO section of the following code, thanks. </p>
  
  <pre><code>/**
   * Select list of jobOccurrences belongs to particular list of jobs
   */
  private List&lt;Job_Occurrence__c&gt; getJobsByJobCode(List&lt;Job__c&gt; jobList) {
  
   // Select relevant Job Occurrence objects 
      List&lt;Job_Occurrence__c&gt; jobOccuList = new List&lt;Job_Occurrence__c&gt;();
  
      for (Job__c job : jobList) {  
  
           Job_Occurrence__c jobOccurrence = [SELECT Id, Job__c,  
                                                     Schedule_Start_Date__c 
                                              FROM Job_Occurrence__c 
                                              WHERE Job__c =: job.Id];
  
           if((jobOccurrence != null) &amp;&amp; (jobOccurrence.Id != null)) {
              jobOccuList.add(jobOccurrence);
           }        
      }   
  
      if((jobOccuList != null) &amp;&amp; (jobOccuList.size() &gt; 0)) {
  
         // TODO
         // How I sort the 'jobOccuList' with Date field 'Schedule_Start_Date__c',   
         // for select the items according to sequence of latest jobOccurrence    
  
         return jobOccuList; 
  
      } else {
         throw new RecordNotFoundException ('Could not found any jobOccurrence for given list of jobs');   
      }                            
  }
  </code></pre>