Aspen:Sort Links
From Aspen Documentation
Note: As noted in bug 1199 this function requires that clean url support be disabled.
When displaying tabular data, you often need a way of creating column header text links that resort the query by the column in ASCending order, or DESCending order.
To create a link into a sort altering link, just use the following:
<?php print $this->sortLink('ColumnName', 'table_key', 'fieldname'); ?>
In the above function, we first specify text that will be printed inside of the anchor element. The second argument is a special text identifier that you create to identify this table. This value when saving user sort preferences to the database.
The third argument is the field in your query that this should resort. All sorting begins with ASC order. If clicked a second time, the order changes to DESC.
The system will save the sort preferences for the user if enabled, and will automatically restore those settings when the user returns.
The model class will automatically load the values from the url, but will revert to default sorting if the fields don't seem to exist in the last query.