Problem: We have a requirement where we need to sort lead records based on Company field first and then based on Name.
Solution: Yes, we can sort records based on multiple fields as well.
List<Lead> lstLead = new List<Lead>();
lstLead = [Select id,company,name from Lead where name != null order by Company Asc,name ASC];
system.debug('Sorted Lead Records'+lstLead);
Solution: Yes, we can sort records based on multiple fields as well.
List<Lead> lstLead = new List<Lead>();
lstLead = [Select id,company,name from Lead where name != null order by Company Asc,name ASC];
system.debug('Sorted Lead Records'+lstLead);