Hi, i chose to implement a simple dialog choice as a dropdown with Ascending/Descending.
<sortingOrder jcr:primaryType="cq:Widget" defaultValue="asc" fieldLabel="Sort" name="./sorting-order" type="select" xtype="selection"> <options jcr:primaryType="cq:WidgetCollection"> <asc jcr:primaryType="nt:unstructured" text="Ascending" value="asc"/> <desc jcr:primaryType="nt:unstructured" text="Descending" value="desc"/> </options> </sortingOrder>
Then you can use this in a number of ways.
If you want to make use of the standard cq list there is a possibility to create you own comparator(or one for sorting asc and one for desc) to pass onto the list with the funtion setOrderComparator(Comparator<Page> obc). This comparator then has to sort the pages differently depending on the choice in the dropdown. There are loads of examples on the web how you implement of a comparator.
There is also an option to pass a querybuilder to the list itself in which you have to supply the parameters for a query to fetch the resources of your choice. In this you can then pass the chosen parameter for the sorting so that the query ultimately returns the list of results in the right order. A small code example below:
Map<String, String> map = new HashMap<String, String>(); //... add the rest of the options here map.put("orderby.sort", SORTING_ORDER_VALUE); //Here you put the value for sortingThis documentation will also help you with that:
http://dev.day.com/docs/en/cq/current/dam/customizing_and_extendingcq5dam/query_builder.html
Good luck
/johan