c# - How to sort case insensitive with System.Dynamic.Linq? -


i use system.linq.dynamic order items list.

items = items.asqueryable().orderby("name asc"); 

to surprise, lowercase names gets ordered after capital cased names, items returned this.

ape cat dog alligator ant beetle 

i expected order:

alligator ant ape beetle cat dog 

is there way correct order? checked method signatures orderby , googled around, nada.

you must create custom comparer, such as:

public void main()  {        string[] words = { "apple", "abacus", "branch", "blueberry", "clover", "cherry" };       var sortedwords = words.orderby(a => a, new caseinsensitivecomparer());       objectdumper.write(sortedwords);  }   public class caseinsensitivecomparer : icomparer<string>  {      public int compare(string x, string y)      {          return string.compare(x, y, stringcomparison.ordinalignorecase);      }  } 

found @ https://code.msdn.microsoft.com/sql-ordering-operators-050af19e


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -