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:
student
students
Student
Students
For an instance:
using System;
using System.Collections.Generic;
namespace Dela.Mono.Examples
{
public class HelloWorld
{
public static void Main(string[] args)
{
List<string> list = new List<string>();
list.Add("student");
list.Add("students");
list.Add("Student");
list.Add("Students");
list.Sort();
for (int i=0; i < list.Count; i++)
Console.WriteLine(list[i]);
}
}
}
it sorts the string as:
student
Student
students
Students
If I try to use list.Sort(StringComparer.Ordinal)
, the sorting goes like:
Student
Students
student
students