title: Difference in sorting between .NET 3.5 and .NET 4.0
body: <p>I've come across a very weird behaviour of the .NET framework(s), when sorting a collection.
  This behaviour is different between .NET 3.5 and 4.0 (<a href="https://stackoverflow.com/questions/5123886/why-does-net-4-0-sort-this-array-differently-than-net-3-5">but I think I know why</a>), but more importantly (and that's my real concern here), <strong>the behaviour is different accross different machines on the same framework</strong>.</p>
  
  <h2>Context</h2>
  
  <p>I'm working on a piece of software that's relying on some third party software (spring.net in this case but it doesn't matter), and at some point, it's sorting a collection that has all its item "equal" (the comparer always return 0). This is <strong>NOT</strong> under my control and I'd be very fine with it if the behaviour of sorting that list was always consistent. It's not.</p>
  
  <h2>How to reproduce</h2>
  
  <p>Create a simple project, <strong>in .NET 3.5</strong>, and run the code below.
  When compiled in 3.5, the behaviour seems to be consistent, and the collection will be "reversed" (it comes out as <strong>Three, Two, One</strong>).
  Now, please change the project target to <strong>.NET 4 (<em>not 4.5</em>)</strong>, and run it again:
  On my machine, it doesn't reverse the collection anymore (One, Two, Three), but on some other colleagues machine, it does (Three, Two, One)!!! We have exactly the same setup...</p>
  
  <p><strong>Can you please tell me, on your machine, under 4.0, which it is? Reversed or not reversed?</strong></p>
  
  <p>I'm trying to assess whether my setup is correct, or not.</p>
  
  <h2>Proof of concept</h2>
  
  <pre><code>class Program
  {
      static void Main()
      {
          var collection = new ArrayList
          {
              "One",
              "Two",
              "Three",
          };
  
          // It should in any case write One, Two, Three
          Console.Out.WriteLine("Before sort: ");
          foreach (string item in collection)
          {
              Console.Out.WriteLine("\t"+item);
          }
  
          collection.Sort(new OrderComparator());
  
          // In .NET 3.5, it will write Three, Two, One
          // In .NET 4, it will sometimes write Three, Two, One, sometimes One, Two, Three: what is it for you?
          Console.Out.WriteLine("After sort: ");
          foreach (string item in collection)
          {
              Console.Out.WriteLine("\t" + item);
          }
  
          Console.Out.WriteLine("--end--");
          Console.Read();
      }
  }
  
  public class OrderComparator : IComparer
  {
      public virtual int Compare(object o1, object o2)
      {
          return 0;
      }
  }
  </code></pre>
  
  <p>Also, if you have any idea why this is happening, please let me know!</p>