As far as I know there is no
Sort
method available to directly sort the
Rows
of a
DataTable
.
One option is to use
DefaultView
, sort it and then use the
ToTable
method to obtain a sorted datatable, as shown below
DataView dataView = DataTable1.DefaultView;
dataView.Sort = "Id";
DataTable sortedTable = dataView.ToTable();
Other option is to use
DataTable.Select
method as as mentioned by
Nathan Stiles in the comment to the question, but with this method an
Array
of
DataRow
objects is obtained.