Any one please help me to understand why C# Sort failed? C# Sort vs Java Sort
********\nI have used C# list.Sort() during contest and failed at this below test case. After research, it turns out that C# .Sort() function failed to sort the
************************************************\nI have used C# list.Sort() during contest and failed at this below test case. After research, it turns out that C# .Sort() function failed to sort the strings properly when strings are mix of lower and upper case.  JAVA list.sort() function worked fine as expected.\n\nDoes any one know why C# list.Sort() failed? Is this a known issue?\n***********************************************\n\nFood Items are sorted alphabetically in most of the cases. Please help me what I am missing. Thank you\n\n![image](https://assets.leetcode.com/users/venendroid/image_1587268881.png)\n\n====More info===\n![image](https://assets.leetcode.com/users/venendroid/image_1587270047.png)\n\n\n**I fixed my solution by using CompareOrdinal\n  fList.Sort((f1, f2) => string.CompareOrdinal(f1, f2));**\n  Ref: https://leetcode.com/problems/display-table-of-food-orders-in-a-restaurant/discuss/586500/Accepted-C-Solution.-Dictionaries-%2B-Sort\n\nBut still curious why default **c# sort function failed** to sort the strings properly**. **In java, it is working as expected**.**\n\n**My working Solution:**\n```\n public IList<IList<string>> DisplayTable(IList<IList<string>> orders) \n    {\n      Dictionary<int, Dictionary<string, int>> d = new Dictionary<int, Dictionary<string, int>>();   \n      HashSet<string> h = new HashSet<string>();\n        \n      foreach(var list in orders)\n      {\n         var table = Convert.ToInt32(list[1]);\n         var item = list[2];\n          \n         h.Add(item);\n          \n         if(d.ContainsKey(table))\n         {\n             var dic = d[table];\n             if(dic.ContainsKey(item))\n                 dic[item]++;\n             else\n                 dic.Add(item, 1);\n          }\n          else\n          {\n              var dic = new Dictionary<string, int>();\n              dic.Add(item, 1);\n              d.Add(table, dic);\n          }\n      }\n       \n      var res = new List<IList<string>>();\n      var fList = h.ToList();\n       fList.Sort((f1, f2) => string.CompareOrdinal(f1, f2));\n        \n       res.Add(fList);\n        \n       var items = from pair in d \n                           orderby pair.Key ascending \n                              select pair; \n       \n       foreach(var kv in items)\n       {\n         var l = new List<string>();\n          l.Add(kv.Key.ToString());\n           \n          var dic = kv.Value;\n           \n          foreach(var f in fList)\n          {\n              l.Add(dic.ContainsKey(f) ? dic[f].ToString():"0");\n          }\n           \n          res.Add(l); \n       }\n        \n       res[0].Insert(0, "Table"); \n        \n      return res;  \n    }\n```\n\n\n\n
[]