I need to sort the column based on ID .
Input is : ID Brand
k123-400 ABC
k122-400 QWE
k123-402 ASD
k122-401 ZXC
expected result is
ID
Brand
k122-400
QWE
k122-401
ZXC
k123-400
ABC
k123-402
ASD
How to perform slip and do sorting using sort Datatable …Kindly help
Anil_G
(Anil Gorthi)
December 22, 2023, 10:50am
2
@tharani.natarajan
Please try this in assign
dt = dt.AsEnumerable.OrderBy(function(x) Cint(x(0).ToString.Split("-"c)(1))).CopyToDataTable
cheers
1 Like
ppr
(Peter Preuss)
December 22, 2023, 10:53am
3
One of many options (we assume input 1 col datatable)
prepare result datatable with build datatable (2 cols) - dtResult
Assign Activity:
dtResult =
(From d in dtInput.AsEnumerable
Let arrSplit = d("ColName").toString.Trim.Split(" "c)
Let ra = arrSplit.Cast(Of Object).toArray
Order by arrSplit(0)
Select r = dtResult.Rows.Add(ra)).CopyToDataTable
we would do some addtional enhancements e.g. values cleansing, numerical ordering
@tharani.natarajan
input
ID Brand
k123-400 ABC
k122-400 QWE
k123-402 ASD
k122-401 ZXC
try this
yourDataTableVar = yourDataTableVar.AsEnumerable().OrderBy(Function(row) row("ID")).CopyToDataTable()
cheers…!!!
2 Likes
vrdabberu
(Varunraj Dabberu)
December 22, 2023, 11:49am
6
Hi @tharani.natarajan
sortedDt= (From row In dt.AsEnumerable()
Order By row.Field(Of String)("ID")
Select row).CopyToDataTable()
Refer the below workflow for better understanding
Sequence.xaml (8.3 KB)
Regards,
1 Like
Hi @tharani.natarajan
Use below expression
DT = DT.AsEnumerable.OrderBy(Function(row) row(“ID”)).CopyToDataTable
Hope it will helps you
Cheers!!
1 Like
system
(system)
Closed
January 3, 2024, 8:05am
9
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.