+ Start a Discussion
Rajesh SFDCRajesh SFDC 

how to sort names based on total field in apex

select id,Name,patientcount__c,Refferal_To_Count__c,color__c,CreatedDate,lastmodifieddate,Referral_Type__c  from Account where   Id IN :  ac1 OR Id IN : ac2   order by Referral_Type__c asc, patientcount__c desc 
1.Referral_Type__c  is picklist . its working fine
2.patientcount__c  is total based on total, i want to display the account names is Desc order , in this query its not  working for  me 
Balaji Chowdary GarapatiBalaji Chowdary Garapati
@Rajesh SFDC:

  Try implementing "Comparable" interface in your code to perform custom sort which gives you more flexibility in sorting. For reference, please follow the below link:
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_list_sorting_sobject.htm and refer "Custom Sort Order of sObjects" section in it.