Skip to main content

ORDER BY

public inherited sharing class AccountSelector {

public static SOQL Query {
get {
return SOQL.of(Lead.sObjectType)
.with(new List<sObjectField>{
Account.Id,
Account.Name,
Account.Industry
});;
}
}
}

public with sharing class MyController {

public static List<Account> getAccounts() {
/*
SELECT Id, Name, Industry
FROM Account
ORDER BY Industry DESC NULLS FIRST, Id ASC NULLS FIRST
*/
return AccountSelector.Query
.orderBy(Account.Industry).sortDesc()
.orderBy(Account.Id)
.asList();
}
}