You need to sign in to do that
Don't have an account?
NickDev
Comparable Interface for Objects inside a Wrapper Class
Hi,
I have a Wrapper Class which has two object type's declared inside it which stored in it.
I'm then adding an instance of this class to a list. The reason I had to do this is because there is a polymorphic field in the ProcessWorkItem object and I needed to loop through all records to get the related information.
The problem is, I cannot get the Comparable Interface working on these objects in order to sort the list accordingly.
The code executes without errors but the list is not sorted.
I've triggering this by using myList.sort();
Any help would be great
I have a Wrapper Class which has two object type's declared inside it which stored in it.
I'm then adding an instance of this class to a list. The reason I had to do this is because there is a polymorphic field in the ProcessWorkItem object and I needed to loop through all records to get the related information.
The problem is, I cannot get the Comparable Interface working on these objects in order to sort the list accordingly.
The code executes without errors but the list is not sorted.
I've triggering this by using myList.sort();
public Class MyWrapper implements Comparable { public ProcessInstanceWorkitem obj1 {get; set;} public MySalesforceObject obj2 {get; set;} public Integer compareTo(Object o) { MyWrapper comparemyWrp = (MyWrapper)(o); if (SORT_BY == ACTOR_SORT) { return sortByActor(comparemyWrp); } return 0; } private Integer sortByActor(MyWrapper wrap) { if (this.obj2.CreatedDate > wrap.obj2.CreatedDate) { return 1; } if (this.obj2.CreatedDate == wrap.obj2.CreatedDate) { return 0; } return -1; } }
Any help would be great
I meant!