ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / TableView Class / SortAsync Method
The field sort information. When null the sort of the table will revert to database order. If any of the field's sort information is set to FieldSortInfo.AscCase or FieldSortInfo.DescCase, the sort will be case sensitive.
Example Version

SortAsync Method (TableView)
Sorts the attributes in the table view.
Syntax

Parameters

sortFields
The field sort information. When null the sort of the table will revert to database order. If any of the field's sort information is set to FieldSortInfo.AscCase or FieldSortInfo.DescCase, the sort will be case sensitive.

Return Value

Returns True the sort succeeded.
Example
Sort
var tv = TableView.Active;
if (tv == null)
  return;

// sort the active field descending
if (tv.CanSortDescending)
  tv.SortDescending();


// sort the active field ascending
if (tv.CanSortAscending)
  tv.SortAscending();


// peform a custom sort programmatically
if (tv.CanCustomSort)
{
  // sort fields
  var dict = new Dictionary<string, FieldSortInfo>();
  dict.Add("STATE_NAME", FieldSortInfo.Asc);
  dict.Add("CITY_NAME", FieldSortInfo.Desc);
  await tv.SortAsync(dict);
}


// perform a custom sort via the UI
if (tv.CanCustomSort)
  tv.CustomSort();
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3.1 or higher.
See Also