Custom Collation Ordering

前端 未结 2 1363
小蘑菇
小蘑菇 2021-01-15 09:17

Is there a way in .NET/C# to sort a List according to a custom alphabetical order?

I have a list of words:

{ \"badum\", \"         


        
2条回答
  •  不知归路
    2021-01-15 10:00

    You can pass custom sorter to the List.Sort() method:

    List foo = new List();
    foo.Sort((a, b) => a.CompareTo(b));
    

    This will sort the list in place depending on which criteria you want to use (above obviously does just a regular string comparison).

提交回复
热议问题