Is there a standard functionality which will allow me to sort capital and small letters in the following way or I should implement a custom comparator:
stude
I believe you want to group those strings which starts with lower case and upper case, then sort them separately.
You can do:
list = list.Where(r => char.IsLower(r[0])).OrderBy(r => r)
.Concat(list.Where(r => char.IsUpper(r[0])).OrderBy(r => r)).ToList();
First select those string which starts with lower case, sort them, then concatenate it with those strings which start with upper case(sort them). So your code will be:
List list = new List();
list.Add("student");
list.Add("students");
list.Add("Student");
list.Add("Students");
list = list.Where(r => char.IsLower(r[0])).OrderBy(r => r)
.Concat(list.Where(r => char.IsUpper(r[0])).OrderBy(r => r)).ToList();
for (int i = 0; i < list.Count; i++)
Console.WriteLine(list[i]);
and output:
student
students
Student
Students