Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List<> own comparer

I have a List where element is:

struct element { 
                double priority; 
                int value; 
               }

How can I implement my own comparer which allow me sort List by priority ? I try with SortredList... but it don't allow douplicated keys :(

Big thanks for help!

like image 944
netmajor Avatar asked Mar 24 '10 16:03

netmajor


1 Answers

Assuming C# 3 or later:

var sorted = MyList.OrderBy(e => e.priority);
like image 135
Joel Coehoorn Avatar answered Oct 13 '22 19:10

Joel Coehoorn