title: Sort same value fields in list descending
body: <p>How can I sort same value fields in generic lists with a descending order.</p>
  
  <p>Example:</p>
  
  <pre><code>List&lt;int&gt; objList = new List&lt;int&gt;();
  
  objList.Add(1);
  -&gt; objList.Add(0);
  -&gt; objList.Add(0);
  objList.Add(2);
  -&gt; objList.Add(0);
  </code></pre>
  
  <p>It's my source somehow and I want to sort for example zero values in descending mode.</p>
  
  <p>I use this code for sorting the numbers (actually the depths), and above example is not related to this but somehow it's same. In my generic list I have several depths which they might be same to each other and I want to order the same fields descending.</p>
  
  <pre><code>Objects.Sort(
     delegate(Classes.Object.GameObject Object1, Classes.Object.GameObject Object2)
     {
         return Object1.Depth.CompareTo(Object2.Depth);
     }
  );
  </code></pre>
  
  <p><strong>Answer:</strong> Might help someone in the future</p>
  
  <pre><code>    // Reverse same oredered
      CurrentSameOrderedFind = Objects[0].Depth;
      CurrentSameOrderedID = 0;
      for (int i = 1; i &lt;= Objects.Count - 1; i++)
      {
          if (Objects[i].Depth != CurrentSameOrderedFind)
          {
              SameOrederedFound = true;
              Objects.Reverse(CurrentSameOrderedID, i - 1);
              CurrentSameOrderedFind = Objects[i].Depth;
              CurrentSameOrderedID = i;
          }
      }
      if (!SameOrederedFound)
      {
          Objects.Reverse();
      }
  </code></pre>