Sorting Data,,,

I have a DataTable of products with columns
“ProductID”,
“ProductName”, and
“Price”.
LINQ query to sort the products by “Price” in descending order.

Hi @rajmoin136

You can use the below linq expression in assign activity,

- Assign -> Products_DT = Products_DT.AsEnumerable().OrderByDescending(Function(row) Convert.ToDecimal(row("Price").toString)).Copytodatatable()

Hope it helps!!

@rajmoin136

var sortedProducts = from row in dataTable.AsEnumerable()
                     orderby row.Field<decimal>("Price") descending
                     select row;
DataTable sortedTable = sortedProducts.CopyToDataTable();
1 Like

Hi @rajmoin136

productDataTable.AsEnumerable().OrderByDescending(Function(row) Convert.ToDecimal(row("Price"))).CopyToDataTable()

@rajmoin136

Use Sort datatable activity

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