I have an IList
in C#, to be sorted in order according to a number. The problem is with numbers higher than 10 (ex: {11,12,13}). They are sorted before numbers less than 10 (ex: {6,7,8}), so at the end of the sorting I get the model with 11 in the first position, and other models with 6 or 7 in the last positions.
I do pass this order number as a string, I am not sure if this is the problem or if I have written the code wrong. Any suggestions?
Code:
IList<TestGrid> myList = new List<TestGrid>();
foreach (DataRow row in Browse.GridNodes.Rows)
{
TestGrid model = new TestGrid();
model.Name = row["Name"].ToString();
model.Type = row["Type"].ToString();
model.NodeId = row["NodeId"].ToString();
model.ActivOrderNo = ReadAttribute(row["NodeId"].ToString()+".CONFIG.OrderNumber", 13);
myList.Add(model);
}
IList<TestGrid> sortedList = myList.OrderBy(r => r.ActivOrderNo).ToList();