Defines the sort order for the enclosing dsp:sort tag.

<dsp:orderBy property="sort-property" reverse="{true|false}"/>



The property on which to sort. Two constraints apply:


After the item is sorted, determines whether to use the initial order (false) or reverse it (true). If you omit this attribute, the default is false.

Usage Notes

dsp:orderBy specifies the properties used to sort items in the dsp:sort-specified object. Multiple dsp:orderBy tags within the same dsp:sort tag specify multiple sort levels. For example, given a Collection of user profiles, you might sort first on the ages, and within each age, sort on last names, then first names.


<dsp:importbeantomap bean="AllStudents" var="students"/>
<dsp:sort var="sorter" values="${students}">
  <dsp:orderBy property="age" reverse="true"/>
  <dsp:orderBy property="lastName"/>

     <c:forEach var="forEach" begin="0" items="${sorter.sortedArray}">
        <li>Name: <c:out value="${students.lastName}"/>

In this example, the students are ordered first in reverse by age, and then as a secondary sort, they are ordered by last name. The eldest students are returned at the top of the list and those who have the same age are organized alphabetically by last name.

Copyright © 1997, 2014 Oracle and/or its affiliates. All rights reserved. Legal Notices