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

4 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.