Click here to Skip to main content
15,886,664 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to sort a list with multiple parameter
Posted
Comments
[no name] 21-Aug-12 12:00pm    
http://www.codeproject.com/Articles/64628/Code-Project-Quick-Answers-FAQ
Santhosh Kumar Jayaraman 21-Aug-12 12:11pm    
need more info..
[no name] 21-Aug-12 12:22pm    
i want to sort a list with two parameter as (OrderDate) and (NumberReferrences number)
[no name] 21-Aug-12 12:17pm    
i am already tried to sort a list with single parameter

selectedOrderDetails.Sort(delegate(Data.OrderProcessing.OrderSchema order,Data.OrderProcessing.OrderSchema comparerOrder) { return order.OrderDate.CompareTo(comparerOrder.OrderDate); });




it will sort a list with single parameter(OrderDate) to show ASC order

Now,
i want to sort a list (OrderDate) and (NumberReferrences number)

If you are using a List<t> you can use the built in Sort method.
Take a look at the information on this page[^].
Also read this page[^].
 
Share this answer
 
v2
Comments
[no name] 21-Aug-12 12:24pm    
list.sort();

but i want to sorta list with two parameter
BillW33 21-Aug-12 12:28pm    
Look at the second link that I just added.
C#
selectedOrderDetails.Sort(delegate(OrderProcessing.OrderSchema order, OrderProcessing.OrderSchema comparerOrder) { return CompareTo(comparerOrder.OrderDate) != 0 ? order.OrderDate.CompareTo(comparerOrder.OrderDate) : order.ChannelOrderRefNumeric.CompareTo(comparerOrder.ChannelOrderRefNumeric); });
}






I am using like this to sort a list with multiple parameter using conditional operator..

but i didn't use Linq , Icampare...
is single line code to sort.......
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900