Unable to sort the data table

Hi team

I want to sort a data table having the following contents:

Field Label Group Count Percentage
TPLKZ HPUR2 27830 21.39
TPLKZ HPUW1 3866 2.97
TPLKZ HPUR1 1289 0.99
TPLKZ HPUW2 1820 1.40
TPLKZ HPSL2 6000 4.61
TPLKZ HCAB1 56 0.04
TPLKZ HPP01 22263 17.11
TPLKZ HPU 15 0.01
TPLKZ HPUG5 66277 50.93
TPLKZ HPSL1 288 0.22
TPLKZ HPUR3 424 0.33

I want the percentage column to be sorted in descending order, I tried using the sort data table activity but it isn’t working
Can someone help me out with this problem?

thankyou :slight_smile:

Hi,

It might be caused with sorting by string. Can you try the following expression?

sortedDt = dt.AsEnumerable.OrderByDescending(function(r) Double.Parse(r("Percentage").ToString)).CopyToDataTable()

Regards,

thankyou
that worked :slight_smile:

1 Like

this is not working for

IFLOT Filled Rows Filled Percentage
TPLNR 130128 100.00
TPLKZ 130128 100.00
FLTYP 130128 100.00
TPLMA 129178 99.27
ERDAT 130128 100.00
SUBMT 1149 0.88
MAPAR 511 0.39
HERST 30816 23.68
TYPBZ 26616 20.45
SERGE 8955 6.88
EMATN 0 0.00
IWERK 130128 100.00
RBNR 88803 68.24
ILOAN 130128 100.00
OBJNR 130128 100.00
STRNO 130128 100.00

this data table and neither is sort data table
what to do
I need to sort using filled percentage in descending order

Hi,

In my environment, it seems work well.

Can you check the following sample?

Sample20211018-2.zip (9.0 KB)

Regards,

Hi

Hope the below expression would help you resolve this issue

sortedDt = dt.AsEnumerable.OrderByDescending(function(r) Convert.ToDouble(r(“Percentage”).ToString)*100).CopyToDataTable()

Cheers @Aishwarya_Bhargava

it worked thankyou :slight_smile:

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