Sorting a Data Table

This was the shortest way I could find to sort a DataTable without having to create any new variables.

DataTable.DefaultView.Sort = "ColumnName ASC"
DataTable = DataTable.DefaultView.ToTable

Where:

ASC – Ascending

DESC – Descending

ColumnName – The column you want to sort by

DataTable – The table you want to sort

Leave a Comment