Tag Name: <ww:sort />

Description

Sort a List using a Comparator both passed in as the tag attribute.

NOTE: JSP-TAG

A Tag that sorts a List using a Comparator both passed in as the tag attribute. If 'id' attribute is specified, the sorted list will be placed into the PageContext attribute using the key specified by 'id'. The sorted list will ALWAYS be pushed into the stack and poped at the end of this tag.

  USAGE 1: <ww:sort comparator="myComparator" source="myList"> <ww:iterator> <!-- do something with each sorted elements --> <ww:property value="..." /> </ww:iterator> </ww:sort> USAGE 2: <ww:sort id="mySortedList" comparator="myComparator" source="myList" /> <% Iterator sortedIterator = (Iterator) pageContext.getAttribute("mySortedList"); for (Iterator i = sortedIterator; i.hasNext(); ) { // do something with each of the sorted elements } %>  

Attributes

Name

Required

Default

Type

Description

comparator true   java.util.Comparator The comparator to use
source false   Object/String The iterable source to sort
id false   String The id of the tag element.

Back to Taglib Index