title: How can I replicate the behavior of Python's sorted built-in function in C#?
body: <p>I have a list of dictionaries in Python. This list is being passed around as json between web services. Those web services create unique signatures based on the json being passed around. Part of creating the signature is normalizing the data payload and making sure that everything is in the correct order, so I'm doing this (in Python) - which works fine.</p>
  
  <pre><code>data = [{'a': '1', 'b': '2', 'c': 3}, {'d': 3}, {3: 1}, {'100': '200'}]
  sorted(data)
  &gt; [{3: 1}, {'100': '200'}, {'d': 3}, {'a': '1', 'c': 3, 'b': '2'}]
  </code></pre>
  
  <p>Now, I need to add a C# application into the mix which needs to be able to create the exact same signature as the Python code does. I have not discovered the secret sauce to sort the above data structure in the same way as Python's <code>sorted</code> builtin function.</p>
  
  <p>I'm using <a href="https://servicestack.net/" rel="noreferrer">ServiceStack</a> to parse the json data.</p>
  
  <p>I was hoping that it would be as easy as doing something like this (in C#):</p>
  
  <pre><code>var jsonPayload = "[{\"a\": \"1\", \"b\": \"2\", \"c\": 3}, {\"d\": 3}, {3: 1}, {\"100\": \"200\"}]";                                                                        
  var parsedJson = JsonArrayObjects.Parse(jsonPayload);                                                                                                                        
  parsedJson.Sort();  
  </code></pre>
  
  <p>However, I get this exception from the above C# code:</p>
  
  <pre><code>`At least one object just implement IComparable`
  </code></pre>
  
  <p>I understand why I'm getting this error, but I'm not sure what I should do about it. I really was hoping that I would not have to roll my own sorting logic. The actual data that I'm dealing with is very dynamic. This is just an example of something that is preventing me from moving forward.</p>
  
  <p>Does anyone have any suggestions or recommendations on how I can get a sort in C# to work like the <code>sorted</code> python function for this type of nested data structure?</p>
  
  <p>Thanks!</p>