How do I use a Lambda expression to sort INTEGERS inside a object?
        Posted  
        
            by punkouter
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by punkouter
        
        
        
        Published on 2010-05-04T15:31:55Z
        Indexed on 
            2010/05/04
            15:38 UTC
        
        
        Read the original article
        Hit count: 270
        
lambda-expressions
|collections
I have a collection of objects and I know that I can sort by NAME (string type) by saying
collEquipment.Sort((x, y) => string.Compare(x.ItemName, y.ItemName));
that WORKS.
But I want to sort by a ID (integer type) and there is no such thing as Int32.Compare
So how do I do this? This doesnt work
collEquipment.Sort((x, y) => (x.ID < y.ID); //error
I know the answer is going to be really simple. Lambda expressions confuse me.
© Stack Overflow or respective owner