function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Quang DuQuang Du 

Need help with sort list in Descending order

The controller compile error is  "Return value must be of type: List".  Thanks everyone for your help, much appreciated.

Part of VF template code:
<apex:repeat var="CurrItem" value="{!relatedto.BMCServiceDesk__Incident_Histories__r}">
<apex:outputPanel rendered="{!CurrItem.BMCServiceDesk__actionId__c = 'Notes'}">
<tr> <td colspan="4" class="hdr"><pre>{!CurrItem.BMCServiceDesk__note__c}</pre>&nbsp;
<apex:outputText value="{0,date,MM/dd/yyyy h:mm a}"> <apex:param value="{!CurrItem.BMCServiceDesk__date__c - (5/24)}"/></apex:outputText></td> </tr> </apex:outputPanel> </apex:repeat>

Controller:
public class sortedController {
    
    public ID attributeNoteID {get; set;}

    public List<Note> getNote() {

       Return [         
            SELECT Id, BMCServiceDesk__note__c, BMCServiceDesk__date__c
            FROM BMCServiceDesk__IncidentHistory__c
            WHERE BMCServiceDesk__actionId__c = 'Notes' AND BMCServiceDesk__incidentId__c = :this.attributeNoteID
            ORDER BY BMCServiceDesk__date__c DESC
        ];

    }
}

 
Best Answer chosen by Quang Du
VineetKumarVineetKumar
You will have to do the sorting in controller, and assign that controller to a component and utilize that in VF page.
Reference : https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_email_templates_with_apex.htm

All Answers

VineetKumarVineetKumar
Your return type is wrong. Try the below code:
public class sortedController {          
	public ID attributeNoteID {get; set;}     
	public List<BMCServiceDesk__IncidentHistory__c> getNote() {        
		Return [SELECT Id, BMCServiceDesk__note__c, BMCServiceDesk__date__c             
				FROM BMCServiceDesk__IncidentHistory__c             
				WHERE BMCServiceDesk__actionId__c = 'Notes' AND BMCServiceDesk__incidentId__c = :this.attributeNoteID             
				ORDER BY BMCServiceDesk__date__c DESC];     
	}
}
List<Note> replaced by List<BMCServiceDesk__IncidentHistory__c>
VineetKumarVineetKumar
You will have to do the sorting in controller, and assign that controller to a component and utilize that in VF page.
Reference : https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_email_templates_with_apex.htm
This was selected as the best answer