You can set a FieldSettings object’s LabelClickAction property to a LabelClickAction enumeration value to enable sorting. Your end users can sort a field by clicking its header if a Field object’s LabelClickActionResolved property resolves to one of the following values:
SortByOneFieldOnly - Your end users can sort a field by clicking on its header; however, they will not be able to sort by multiple fields. After your end users sort a field, they can click its header to toggle between ascending and descending sort order.
SortByMultipleFields - Your end users can hold down the CTRL key and click several field headers to sort by multiple fields. Just like the SortByOneFieldOnly enumeration value, your end users can toggle between ascending and descending sort order.
SortByOneFieldOnlyTriState - Your end users can sort a field by clicking on its header. After your end users sort a field, they can click its header to cycle between unsorted, ascending, and descending sort order.
SortByMultipleFieldsTriState - - Your end users can hold down the CTRL key and click several field headers to sort by multiple fields. Just like the SortByOneFieldOnlyTriState enumeration value, your end users can cycle between unsorted, ascending, and descending sort order.
Even if you disable sorting by setting the LabelClickAction property to Nothing or SelectField, you can still sort a field programmatically. In addition, you can further modify sorting-related behaviors by setting the following properties exposed by the FieldSettings object:
SortComparer - You can provide your own sorting logic by setting this property to an object that implements the IComparer interface found in the .NET Framework.
SortComparisonType - You can set this property to a FieldSortComparisonType enumeration value to determine whether the default sorting logic is case-sensitive.
Finally, the Field object and LabelPresenter object both expose a read-only SortStatus property that you can use to determine a field’s current sort status. If you need to determine a field’s sort order in code, use the Field object’s SortStatus property. However, if you are creating a style or template for the LabelPresenter object, you can use its SortStatus property in a trigger to hide or show a sorting indicator.