I am trying to sort a list of strings using the German alphabet's phonebook ordering. In the German alphabet sort, the special characters, or umlauts, are represent by the following:
- Ä -> ae
- Ö -> oe
- Ü -> ue
Therefore, the ascending sort order should end up something like this:
- Ad
- Ä
- Af
I am working in the C# universe and have been using the CultureInfo to create a new string comparer for the sorting. Using this, I get the following order:
- Ä
- Ad
Af
List<string> l = new List<string>(); l.Add("Ad"); l.Add("Ä"); l.Add("Af"); var comparer = StringComparer.Create(CultureInfo.CreateSpecificCulture("de"), true); var x = l.OrderBy(y => y, comparer); foreach(var outp in x) { Console.WriteLine(outp); }
Does anyone know how I could do this with a custom comparer or using an existing culture comparer?