There\'s no Sort()
function for IList
. Can someoene help me with this?
I want to sort my own IList.
Suppose this is my IList:
Use OrderBy
Example
public class MyObject()
{
public int number { get; set; }
public string marker { get; set; }
}
IList myobj = new List();
var orderedList = myobj.OrderBy(x => x.marker).ToList();
For a case insensitive you should use a IComparer
public class CaseInsensitiveComparer : IComparer
{
public int Compare(string x, string y)
{
return string.Compare(x, y, StringComparison.OrdinalIgnoreCase);
}
}
IList myobj = new List();
var orderedList = myobj.OrderBy(x => x.marker, new CaseInsensitiveComparer()).ToList();