0

I have a list of objects I am querying and I am sorting it by start__c field which is a Date/Time type.

List<Notification__c> notifs = [SELECT id FROM Notification__c  
                  WHERE Read__c=false ORDER BY Start__c DESC]; 

When the Date/Time field is different it is working as expected displaying in the descending order. But if the start__c is same for all Notification list,it is displaying in an unordered list.

What is the order in that case?

1
  • Well, the list is ordered, it just that ordering is not consistent because the field you are ordering on has same value. You can order by 2 different fields. First by Start__c and then by something else.
    – manjit5190
    Apr 23, 2020 at 11:03

1 Answer 1

3

You can simply extend the order by to include additional fields (in a hierarchy format) such as:

select id
from Contact
order by CreatedDate, LastModifiedDate, Name

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .