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!


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.

| improve this answer | |
  • Thanks! I was looking for a confirmation. I'll keep the question open for sometime to get other ideas(if any). – Vignesh Damodharan Feb 5 '15 at 8:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.