0

i have model class called SCARF and it has ID,title,name,price property the name property is unique for every SCARF but title dont i have plenty SCARf with same title i want to sort SCARF by title and show it to view by title

amirreza
  • 1
  • 1
  • Sorting implies a collection, like `List` so you can use LINQ in your controller (or view) to sort: `var sortedList = unsortedList.OrderBy(s => s.Name).ToList();` Then in your view use a `foreach` with table rows to display the data. – Steve Greene Dec 05 '19 at 03:03
  • please check this solution https://stackoverflow.com/a/57371579/6923146 – Hardik Masalawala Dec 05 '19 at 06:27

1 Answers1

0

I suppose you have a collection of SCARF class, List<SCARF>. you just need to call OrderBy method of List.

var sortedList = scarfsList.OrderBy(s => s.Title).ToList();
Nouman Janjua
  • 410
  • 2
  • 9