### Sort Sample

This page is an example that illustrates the different results you can get when sorting by a single column and sorting with a secondary and tertiary column specified.

Unsorted
ID | First Name | Last Name | ds_RowID
--- | --- | --- | ---
{@id} | {firstname} | {lastname} | {ds_RowID}

Sort Column: "{dsEmployees1::ds_SortColumn}"
Sort Order: "{dsEmployees1::ds_SortOrder}"

Sort: "firstname"
ID | First Name | Last Name | ds_RowID
--- | --- | --- | ---
{dsEmployees2::@id} | {dsEmployees2::firstname} | {dsEmployees2::lastname} | {dsEmployees2::ds_RowID}

Sort Column: "{dsEmployees2::ds_SortColumn}"
Sort Order: "{dsEmployees2::ds_SortOrder}"

Sort: [ "firstname", "lastname" ]
ID | First Name | Last Name | ds_RowID
--- | --- | --- | ---
{dsEmployees3::@id} | {dsEmployees3::firstname} | {dsEmployees3::lastname} | {dsEmployees3::ds_RowID}

Sort Column: "{dsEmployees3::ds_SortColumn}"
Sort Order: "{dsEmployees3::ds_SortOrder}"

Sort: [ "firstname", "lastname", "@id" ]
ID | First Name | Last Name | ds_RowID
--- | --- | --- | ---
{dsEmployees4::@id} | {dsEmployees4::firstname} | {dsEmployees4::lastname} | {dsEmployees4::ds_RowID}

Sort Column: "{dsEmployees4::ds_SortColumn}"
Sort Order: "{dsEmployees4::ds_SortOrder}"

### Using spry:sort

spry:sort is an attribute of convenience for sorting data sets. It is functionaly equivalent to using onclick="ds.sort('colname', 'toggle');".

The format of the attribute is as follows:

    spry:sort="[dsName] col [col2 ... coln] [order]"

Both the data set name and the sort order to use are *optional*, but if specified, they *must* appear in the order above. You must specify at least one column to sort on, but you can also specify more columns for secondary, tertiary, etc sorts.

If a data set is not specified, the sort defaults to sorting whatever data set is listed first in the spry:region. If sort order is not specified, it defaults to toggle.

ID | Sort First and Last Name | Last Name and ID | ds_RowID
--- | --- | --- | ---
{@id} | {firstname} | {lastname} | {ds_RowID}