Sort DataTable based on column value

datatable
excel
activities

#1

Hi,

I have an Excel looking like this:

Column1, Column2, Column3
XX, XX, -1040
XX, XX, -104
XX, XX, -1072
XX, XX, -1087
XX, XX, -111

I want to read this and sort the DataTable based on valuesd in “Column3”. This is the result using when using DataView.Sort(ascending):

-104
-1040
-1072
-1087
-111

This is of course not the result im looking for. Does anyone have any idea how i can do this sorting?


How to sort a column (Price) from an excel file?
#2

@Johan_Lundstrom, Use this query,

Assign activity

datatable dt =(From row In dt2.Select Order By Convert.ToInt32(row("Column1")) Select row).ToArray.CopyToDatatable()

Many More References

  1. Re order data table and writting Excel (simple questions)
  2. Upath - Sort Datatable

Regards,
Dominic :slight_smile:


Sort elements in a excel document and save it in a new sheet
#5

please watch this