Kumar802
(Kumar802)
1
hello,
I would need to sort a datatable for a specific column: “Column1”
The rules I should follow are as follows:
- First only the numericals, in ascending order
- Then the alphanumerics, in ascending order (ex. 100a - 100b - 101a)
- Then those containing only letters, in ascending order
Is it possible to handle this casuistry via a linq? In what way?
Thank you
BlankProcess22.zip (13.8 KB)
Please download and run hopefully it is what you want
Kumar802
(Kumar802)
3
Thanks for the help, but…
this is the expected result

Yoichi
(Yoichi)
4
Hi,
How about the following?
dt = dt.AsEnumerable.Where(Function(r) System.Text.RegularExpressions.Regex.IsMatch(r(0).ToString,"^\d+$")).OrderBy(Function(r) Double.Parse(r(0).ToString)).Concat(dt.AsEnumerable.Where(Function(r) System.Text.RegularExpressions.Regex.IsMatch(r(0).ToString,"[A-Za-z]") AndAlso System.Text.RegularExpressions.Regex.IsMatch(r(0).ToString,"\d") AndAlso System.Text.RegularExpressions.Regex.IsMatch(r(0).ToString,"^[0-9A-Za-z]+$")).OrderBy(Function(r) r(0).ToString)).Concat(dt.AsEnumerable.Where(Function(r) System.Text.RegularExpressions.Regex.IsMatch(r(0).ToString,"^[A-Za-z]+$")).OrderBy(Function(r) r(0).ToString)).CopyToDataTable
Sample20220706-2.zip (2.8 KB)
Regards,
1 Like
system
(system)
Closed
5
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.