You need to sign in to do that
Don't have an account?

Group by in Wrapper List
Hi I have a wrapper class in which i have a boolean variable. Now i have a list of Wrapper Class which i have to show on VF page, now i want to show the table in such a way that true values comes first and then false. Now i want to prepare a wrapperlist such that all true records come first and then records with false value.
Your VF page would then include "{!wrapperList}" to reference the return value of this method.
All Answers
Your VF page would then include "{!wrapperList}" to reference the return value of this method.
If you are wrapping sobjects that are the result of a query, then you could use ORDER BY in the query to get the list from the database in a specifi order. When this ordered list from the database is split into the true/false grouping, each of the two groups will still retain the order of the original query result, being separated now by the true/false flag in the wrapper class.
Another option might be as follows... to ask the wrapper instance who it belongs to. Suppose your wrapper included an Integer property, called "category" that would return value based on some evaluation of itself. You could iterate through the wrapper instances, putting each one into a map of lists... Map<Integer, List<Wrapper>>..., then get the keyset into list, sort that list ascending, and use the previous getter method to group them into true/false according to your original question.
Is this the sort of grouping within the true/false segments you are interested in obtaining?