I tried to sort a data table with following two ways
table.DefaultView.Sort = "Town ASC, Cutomer ASC" table.Select("", "Town ASC, Cutomer ASC")
But none of them wasn't worked. It always displays data in original order. Do you have any idea to solve the problem.
Sorting allows the user to reorder rows by the contents of a column. This is a live continuous sort , and new rows that get added or rows that get edited will be resorted immediately after, and you will not be able to manually reorder rows. You can sort on multiple columns with multiple sort directions.
To sort a data frame in R, use the order( ) function. By default, sorting is ASCENDING. Prepend the sorting variable by a minus sign to indicate DESCENDING order.
To sort a table in Excel by a single column, click into a cell within the column by which to sort the data. To sort the table in either ascending or descending order by the column's data values, click either the “Sort A to Z” or “Sort Z to A” buttons in the “Sort & Filter” button group on the “Data” tab in the Ribbon.
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
Try this:
Dim dataView As New DataView(table) dataView.Sort = " AutoID DESC, Name DESC" Dim dataTable AS DataTable = dataView.ToTable()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With