How do you sort two columns in descending order?

Hello,

I’d like to sort it into two columns in the uipath.
I found

(From x In DataTableName.AsEnumerable() Order By convert.Tostring(x(“col1”)),convert.ToString(x(“col2”)) Select x).CopyToDataTable

this expression…

But it should be sorted in descending order.
I want to sort in descending order, not ascending.
For example…
col1 col2
9 5
9 2
8 7
8 2
8 1
4 9
4 4
3 5
2 7
2 1

I need your help.
Thanks

Hi @youngchang

Check out this video

Regards
Gokul

Hi @youngchang
please try this one

(From x In datatable.AsEnumerable() Order By convert.ToInt32(x(“Column1”)), convert.ToInt32(x(“Column2”)) Select x).CopyToDataTable

Hi @youngchang

How about tis expression

(From x In DtBuild.AsEnumerable() Order By Convert.ToString(x("Column1")) Descending Select x).CopyToDataTable

Check out the XAML file

DescendingOrder.xaml (8.0 KB)

Regards
Gokul

@youngchang ,

An Alternate using Method Syntax :

DT.AsEnumerable.OrderByDescending(Function(x)CDbl(x("col1").ToString)).ThenBy(Function(x)CDbl(x("col2").ToString)).CopyToDatatable

This is in case you want to sort it first by First Column and then by the second column.

Hello @youngchang

You can use either of the below activities.

image

If you still want to proceed with linq expression you can watch the below video.

Thanks

It’s sorting in ascending order…

Didn’t work as i thought…TT

IT WORKS!! IT WORKS!!!
This is what i wanted!!

Thanks a lot!!

1 Like

It only works on one column…

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