Change C# sorting behaviour

Posted by Erik on Stack Overflow See other posts from Stack Overflow or by Erik
Published on 2010-06-03T15:08:21Z Indexed on 2010/06/03 16:54 UTC
Read the original article Hit count: 371

Filed under:
|
|
|

Lets say i have the strings abc_ and abc2_. Now, normally when sorting i C# abc2_ would come after abc_, leaving the result:

  1. abc_
  2. abc2_

I am using this to sort, if it matters:

     var element = from c in elements
     orderby c.elementName ascending
     select c;

How can i change this? I want abc_ to come last. Reversing is not an option because the list is contains more than two elements.

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ