I have Wrapper class which contains List of Map. After performing some operations that List values order gets changed.
public class TeacherAvailabilityWrapper{
public List<Session__c> session{get;set;}
public Set<Date> dateOnCalender{get;set;}
public Map<Date,List<Session__c>> dateSession{set;get;}
public Map<String,List<Session__c>> sessionByDay{set;get;}
public Integer srno{get;set;}
public String Teacher{get;set;}
public Id IdTeacher{get;set;}
public TeacherAvailabilityWrapper(){
session = new List<Session__c>();
}
}
Now I want to sort List of dateSession. Based on Start_time__c (DateTime)field in session.
How to achieve it using Comparable interface?
I added following code
for(TeacherAvailabilityWrapper twrap: listTeacherAvailWrap){
for(Date twDt: twrap.dateSession.KeySet()){
Session__c[] sessions = twrap.dateSession.get(d);
SessionWrapper[] wrappers = new SessionWrapper[] {};
for (Session__c s : sessions) wrappers.add(new SessionWrapper(s));
wrappers.sort();
sessions.clear();
for (SessionWrapper w : wrappers) sessions.add(w.sob);
}
System.debug('sessionByDay--> '+ twrap.sessionByDay);
}