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
SimrinSimrin 

Order by for list.addAll(list)

Hello,
   
I have a list like below which should be orderBy UserId but it is not as 
public List<ProfileSkillUser> tempResult{get;set;} 
public List<ProfileSkillUser> searchResult{get;set;} 

fucntion{
 for (5 times){
   tempResult = [SELECT UserId,  Name FROM ProfileSkillUser ORDER BY UserId];
   searchResult.addAll(tempResult);
 }
}
But the searchResult is not order by list, how can i achive it
 
Best Answer chosen by Simrin
kevin lamkevin lam
fucntion{
   for (5 times){
      for (ProfileSkillUser userRecord : [SELECT UserId,  Name FROM ProfileSkillUser ORDER BY UserId]) {
         searchResult.add(userRecord);
      }
   }
}