Quick Method Of Sorting On Multiple Properties

by Jon 6/24/2008 7:37:00 AM

I’ve started replacing my custom List<T> sorts of

 

ret.Sort(new Comparison(delegate(MyClass o1, MyClass o2) { return o1.City.CompareTo(o2.City); } ) );

 

.., which doesn't seem to support multiple property sorts when I run Sort() multiple times (and I don're care to glean from the many multi-property sort samples on the web that have tens of lines of method execution), with ..

ret = new List<MyClass>(from r in ret orderby r.State, r.City select r);

Works like a charm. I'm slowly learning to dig LINQ-to-Objects ;)

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

Software Development | C#

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag





Live preview

10/7/2008 9:31:14 PM


 

Powered by BlogEngine.NET 1.2.0.0
Theme by Mads Kristensen

About the author

Jon Davis Jon Davis (aka "stimpy77") is a software and web developer by day and a software and web enthusiast (geek) by night. He was recently a senior web engineer for the enthusiast division of a major magazine publishing company for nearly two years. He has been a programmer, developer, and consultant for web and Windows software solutions professionally since 1997, with experience ranging from OS and hardware support to DHTML programming to IIS/ASP web apps to Java network programming to Visual Basic applications to C# desktop apps.
 
Software in all forms is also his sole hobby, whether playing PC games or tinkering with programming them. "I was playing Defender on the Commodore 64," he reminisces, "when I decided at the age of 12 or so that I want to be a computer programmer when I grow up."
 
Jon is currently engaged in a short-term ASP.NET contract and is available for hire for short-term or permanent work in Phoenix or via telecommute.
E-mail me Send mail

Calendar

<<  October 2008  >>
MoTuWeThFrSaSu
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

View posts in large calendar

Pages

    Recent comments

    Authors

    Tags

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2008

    Sign in