I have a DataTable with a column with strings. Some of these values are multiple strings split by a comma. I would like to sort these values alphabetically within the datatable.
I tried using a For Each loop:
Assign an array by splitting the value based on a comma
Sorting the array
Writing the array back to a string by using String.Join to CurrentRow(“Column”).
This is a really big DataTable though, so it takes way too long.
Give a try at:
Assign Activity:
dtSorted = dtOrig.Clone
Assign Activity:
dtSorted =
(From d In dtOrig.AsEnumerable
Let ars = d("Col2SortName").toString.Trim.Split({","}, StringSplitOptions.RemoveEmptyEntries)
Let sfo = String.Join(",",ars.OrderBy(Function (x) x))
Let ra = New Object(){d(0), sfo}
Select r = dtSorted.Rows.Add(ra)).CopyToDataTable