Adding items to queue ascending order

Hi,

I need to add items into queue based on ascending order

Ex
ID
101
101
101
102
102
103

have to add items into queue in below order

103
102
102
101
101
101

@Kishore_Raj

Try to do a sort before adding

If it is datatable use dt = dt.AsEnumerable.OrderByDescending(function(c) Cint(x("ID").ToString))

Or use sort datatable activity if that works

Cheers

I need to add items based on count of I’ds in ascending order

Ex

ID NO

1A101
1A101
1B102
1C103
1C103
1A101
–—–—----------------
1A101 - 3
1B102-1
1C103-2

Need to add items to queue in below order

1B102. .-1
1C103. -2
1A101 - 3

Hi @Kishore_Raj

Try this:

sortedOutput = YourDataTable.AsEnumerable() _
    .GroupBy(Function(row) row("ID").ToString()) _
    .Select(Function(group) YourDataTable.Clone.LoadDataRow({group.Key, group.Count()}, False)) _
    .OrderBy(Function(row) CInt(row("Count"))) _
    .CopyToDataTable()

sortedOutput is of DataType System.Data.DataTable

Hope it helps!!

1 Like

@Kishore_Raj

Then try this

Dt = dt.AsEnumerable.GroupBy(function(x) x("ID").ToString).OrderByDescending(function(x) x.Count).SelectMany(function(x) x).CopyToDataTable

Cheers

Thanks for your reply, it is working in descending order.is it possible in ascending order also

1 Like

Thank you-worked as expected

2 Likes

@Kishore_Raj

If you find solution for the query please mark it as solution to close the loop.

Happy Automation

Regards

@Kishore_Raj

Just temove descending and it will be ascending then

Happy Automation

Cheers

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