How to sort 2columns based on specific conditions

Hai all,
I have a datatable , in that I need to sort one column with albhatical order and other column should be ascending numbers… Ascending numbers is mandatory like 0,0,1,1,2,3… Based on this the other column should sort in alphabetical order…please help me in this. Thanks in advance

Hi @cbhavana ,

Could you provide us with a Sample Data and it’s Corresponding Expected Output. It will be helpful for us to derive the correct solution also in verification.

Also, Do perform an Initial Try with the Below Expression :

DT.AsEnumerable.OrderBy(Function(x)CInt(x("Number Column").ToString)).ThenBy(Function(x)x("Alphabet Column").ToString).CopyToDatatable

Let us know if this works out for your case.

1 Like

The number column should be always ascending…

@cbhavana ,

As Suggested, Could you provide the Data so that we can be sure of what needs to be implemented ?

@supermanPunch i have given 3 screenshots, for referrence…please check and the logic will b same for all…it should sort like that. If u see 3screen shot u will come to know.

@cbhavana ,

The above Expression seems to be working fine, A More direct expression based on the input data :



Let us know if you are not able to get the Required Output with the given Expression.

Note : You would need to assign the Expression to another Datatable /same Datatable to get the sorted data.

1 Like

This is not working @supermanPunch

@cbhavana ,

Could you let us know what is not working ? What is output received from the Expression ?

@supermanPunch It is working i have given empty datatable without noticing… thanks for the solution

1 Like

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