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)

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


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


(From x In datatablevariable.AsEnumerable() Order By convert.ToInt16(x(“ID”)),convert.ToString(x(“Age”)),convert.ToString(x(“Money”)) Select x).CopyToDataTable


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


Using Assign Activity

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


Glad it Worked,

Happy Automating…

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