Arrange DataTable with Same column values

Hi,

I/m not sure if I am creating a duplicate thread, if yes then apologies for that but I checked all possible threads.

I need to arrange my datatable based on same column values for 1 particular column.
Group by doesn’t work as it’s just keeping the distinct column value and removing others.

Input
image

Output
image
Any suggestions will be very helpful.

@Faraz_Subhani

You can use Sort DataTable activity.

https://docs.uipath.com/activities/docs/sort-data-table

did we try with SORT DATATABLE activity With type of ordering chosen and the column name mentioned so that it does what you expect
Cheers @Faraz_Subhani

@Palaniyappan @lakshman I tried using sort datatable, issue is that my Column will be alphanumeric, for eg - 1234-TJ, Sort dtaatable is having no effect on the order.

mention the colummnname as Group
as seen in picture, it looks like we need to group by that column
Cheers @Faraz_Subhani

1 Like

@Faraz_Subhani

Try this:

DataTable.DefaultView.Sort = "Group DESC"
DataTable = DataTable.DefaultView.ToTable

Hi @Faraz_Subhani
If you want to do Order By Using Specific Column then Use Following Code.
YourDataTable.AsEnumerable().OrderBy(Function(x) cstr(x("YourColumnName"))).CopyToDataTable
Regards

1 Like

hmm…this is strange…sort would work in this case
i wonder why it didnt
Cheers @Faraz_Subhani

This just worked, I am just trying with more complicated data for cross checking, will let you know.

1 Like

sure
Cheers @Faraz_Subhani

Great, this works:-)

1 Like

This works as well, thank for the alternate solution.

1 Like

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