Ordering a Datatable

Hey there,

how to order a datatable with numbers descending?

Thanks a lot!

Hi Katarina,
you can sort DT using “Sort Data Table” activity also you can find below video for more support:

also find below documentation for Activity with example


If you have trouble with SortDataTable activity such as it outputs character-code based sorting, the following LINQ expression will help you.

dt = dt.AsEnumerable.OrderBy(Function(r) Double.Parse(r("targetColumn").ToString)).CopyToDataTable

OR, if there is non-numeric value including blank in the target column, the following might be better.

dt = dt.AsEnumerable.OrderBy(Function(r) If(Double.TryParse(r("targetColumn").ToString,New Double),Double.Parse(r("targetColumn").ToString),Double.MaxValue)).CopyToDataTable


1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.