Sort Excel by multiple column

Lets say I need to sort my dataTable (made from a Excel document) by 3 columns, lets name them:
ID (not unique)
Age
Money

so first, I will sort by ID, then age and then money, without losing the past sorting.

any idea how to make it in UiPath?

1 Like

@MaxyArthes

use Sort Data Table activity to sort the DataTable.

1 Like

using 3 back to back will keep the past sorting? and I forgot to mention, but the ID column is actually a text column in Excel, so I must also force Excel to treat them as number before sorting

1 Like

Hi @MaxyArthes

Fine as you mentioned three consecutive sort datatable activity will keep the previous sorting madeā€¦So that would work for sure buddy.
Then ID column though being text format it will get sorted out as well.
Kindly try this and let know for any queries or clarification
You were almost done
Cheers @MaxyArthes

@MaxyArthes

(From x In datatablevariable.AsEnumerable() Order By convert.ToInt16(x(ā€œIDā€)),convert.ToString(x(ā€œAgeā€)),convert.ToString(x(ā€œMoneyā€)) Select x).CopyToDataTable

6 Likes

The ID column donā€™t get sorted, probably because its strings =/

Ohā€¦! does that column with string contains any special character in it buddy
Cheers @MaxyArthes

Using ā€˜Invoke Codeā€™ ? Getting a syntax error so I might just not be using the good activitie

@MaxyArthes

Using Assign Activity

Had to switch int16 to int32, working perfectly, thanks you :slight_smile:

@MaxyArthes

Glad it Worked,

Happy Automatingā€¦
Cheers

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

Hi all,
Here is the solution without using datatable, can able to do the multiple sorting.

Thank you
Balamurugan.S