Apache Struts 2 Documentation > Home > Guides > Tag Developers Guide > Struts Tags > Tag Reference > Generic Tag Reference > sort
Added by digi9ten, last edited by Ted Husted on Sep 02, 2006  (view change)
Please make sure you have read the test:Tag Syntax document and understand how tag attribute syntax works.

Description

Content pulled from external source. Click here to refresh.

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.

Parameters

An error occurred: https://svn.apache.org/repos/asf/struts/struts2/trunk/docs/tags/SortIteratorTag.html. The system administrator has been notified.

Examples

Content pulled from external source. Click here to refresh.
USAGE 1:
 <s:sort comparator="myComparator" source="myList">
      <s:iterator>
 		<!-- do something with each sorted elements -->
 		<s:property value="..." />
      </s:iterator>
 </s:sort>

 USAGE 2:
 <s: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
    }
 %>