Skip to main content
added 125 characters in body
Source Link
SFDC shaikh
  • 747
  • 3
  • 15
  • 35

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<Session__c> of dateSession. Based on Start_time__c (DateTime)field in session.

How to achieve it using Comparable interface?

applied PPS logic of @Keith C enter image description here

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);
        }
        

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<Session__c> of dateSession. Based on Start_time__c (DateTime)field in session.

How to achieve it using Comparable interface?

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<Session__c> of dateSession. Based on Start_time__c (DateTime)field in session.

How to achieve it using Comparable interface?

applied PPS logic of @Keith C enter image description here

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);
        }
        
added 4 characters in body
Source Link
Ratan Paul
  • 22.8k
  • 14
  • 55
  • 99

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<Session__c> of dateSession. Based on Start_time__c (DateTime)field in session.

How to achieve it using Comparable interface?

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<Session__c> of dateSession. Based on Start_time__c (DateTime)field in session.

How to achieve it using Comparable interface?

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<Session__c> of dateSession. Based on Start_time__c (DateTime)field in session.

How to achieve it using Comparable interface?

added 245 characters in body
Source Link
SFDC shaikh
  • 747
  • 3
  • 15
  • 35

I have Wrapper class which contains List of Map. After performing some operations that List values order gets changed.

public Classclass TeacherWrapperTeacherAvailabilityWrapper{
    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 TeacherAvailabilityWrapper()Integer srno{get;set;}
    public String Teacher{get;set;}
    public dateSession=Id IdTeacher{get;set;}
    public TeacherAvailabilityWrapper(){
       session = new Map<Date,List<Session__c>>List<Session__c>();
     }
}

Now I want to sort List<Session__c> of dateSession. Based on Start_time__c (DateTime)field in session.

How to achieve it using Comparable interface?

I have Wrapper class which contains List of Map. After performing some operations that List values order gets changed.

public Class TeacherWrapper{
     public Map<Date,List<Session__c>> dateSession{set;get;}
     public TeacherAvailabilityWrapper(){
           dateSession= new Map<Date,List<Session__c>>();
     }
}

Now I want to sort List<Session__c> of dateSession. Based on Start_time__c (DateTime)field in session.

How to achieve it using Comparable interface?

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<Session__c> of dateSession. Based on Start_time__c (DateTime)field in session.

How to achieve it using Comparable interface?

Fix title typo
Link
Keith C
  • 137.3k
  • 29
  • 218
  • 458
Loading
added 45 characters in body
Source Link
SFDC shaikh
  • 747
  • 3
  • 15
  • 35
Loading
Source Link
SFDC shaikh
  • 747
  • 3
  • 15
  • 35
Loading