I've a list of wrapper objectsin my controller for which I need to perform some operation(say doLogic()). I want to use the method similar to calling sort method.


//similar to sort

As per my understanding, I need to create a public interface like myInterface and my myWrapper class will have to implement the interface.

What is the next step? How exactly do I get it to work?

Thanks in Advance!

1 Answer 1


The sort method list<Object>.sort() is a method that already exists on list<Object>. The Comparable interface can be implemented on an apex object so that list<Object>.sort() can sort those apex objects.

You seem to be asking how to add a brand new method doLogic() to list<Object> so that you can call list<Object>.doLogic(). I don't think this is going to be possible. What you can do is write MyUtilityClass.doLogic(list<MyWrapperClass>) to process your list of wrappers.

  • Thanks! I was looking for a confirmation. I'll keep the question open for sometime to get other ideas(if any). Feb 5, 2015 at 8:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .