how to use order by in list

L Paul
L Paul
8 Points
4 Posts

Hi,

I am using asp.net mvc 4.0 and working on list of class as:

{
List<AuctionRate> AuctionRateList;
AuctionRate AuctionRate;
foreach (DataRow itemrate in TempDataSet.Tables[0].Rows)
{
if (Convert.ToInt32(itemrate["VendorID"]) != Convert.ToInt32(VendorID)) { TempRateCounter += 1; }
AuctionRate = new AuctionRate();
AuctionRate.AuctionRateID = Convert.ToInt32(itemrate["AuctionRateID"]);
AuctionRate.VendorID = Convert.ToInt32(itemrate["VendorID"]);
AuctionRate.SupplierName = (AuctionRate.VendorID == Convert.ToInt32(VendorID) ? itemrate["VendorName"].ToString() : "S" + TempRateCounter);
AuctionRate.Priority = (AuctionRate.VendorID == Convert.ToInt32(VendorID) ? 0 : TempRateCounter);
AuctionRate.Rate = Convert.ToDecimal(itemrate["Rate"]);
AuctionRateList.Add(AuctionRate);
}
}

 

I want to order by Priority the list after addition item in list.

Please help.

Views: 8124
Total Answered: 1
Total Marked As Answer: 1
Posted On: 22-Sep-2015 04:02

Share:   fb twitter linkedin
Answers
Brian
Brian
Participant
536 Points
73 Posts
Marked as answer      

Hi L Paul,

use this:

AuctionRateList.OrderBy(x => x.Priority).ToList();

 

Posted On: 22-Sep-2015 05:41
banner

Blog

Active User (2)

 Log In to Chat