How to Sort a List in Desending Order by the "Value" and Sort the Duplicates by the "Key"?
<p>I have looked All over the Internet to try and find an example of How to fix the following.</p>

<p>How to Sort a List in Desending Order by the "Value" and Sort the Duplicates by the "Key" ?
Then Print out the Results in the format below.</p>

<p>I have enclosed my code and it works, but the problem happens when there are duplicate values, which occurs when you use SortedList(). I would GREATLY APPRECIATE it if someone could PLEASE Modify this Code or Show me EXACTLY how to do this another way, that is just as quick and efficent.</p>

<p>THANK YOU VERY MUCH in Advance.</p>

<p>BEFORE SORT:</p>

<p>VALUE's,  KEY's</p>

<pre><code>sL.Add(1269.63,"white");
sL.Add(1270.36,"orange");
sL.Add(1272.06,"yellow");
sL.Add(1271.50,"cyan");
sL.Add(1272.06,"black");
sL.Add(1274.12,"dodBlue");
sL.Add(1276.02,"blue");
sL.Add(1273.21,"green");
sL.Add(1275.52,"red");
</code></pre>

<p>AFTER SORT:</p>

<p>VALUE's,  KEY's</p>

<pre><code>sL.Add(1276.02,"blue");
sL.Add(1275.52,"red");
sL.Add(1274.12,"dodBlue");
sL.Add(1273.21,"green");
sL.Add(1272.06,"black");
sL.Add(1272.06,"yellow");
sL.Add(1271.50,"cyan");
sL.Add(1270.36,"orange");
sL.Add(1269.63,"white");
</code></pre>

<p>CODE:</p>

<pre><code>SortedList sL = new SortedList();

sL.Add(SMA(8)[0], "white");
sL.Add(SMA(10)[0], "orange");
sL.Add(SMA(13)[0], "yellow");
sL.Add(SMA(20)[0], "cyan");
sL.Add(SMA(30)[0], "black");
sL.Add(SMA(40)[0], "dodBlue");
sL.Add(SMA(50)[0], "blue");
sL.Add(SMA(100)[0], "green");
sL.Add(SMA(200)[0], "red");

Print("  " + " " + sL.GetByIndex(8) + " " + "&gt;=" + " " + sL.GetByIndex(7));
Print("&amp;&amp;" + " " + sL.GetByIndex(7) + " " + "&gt;=" + " " + sL.GetByIndex(6));
Print("&amp;&amp;" + " " + sL.GetByIndex(6) + " " + "&gt;=" + " " + sL.GetByIndex(5));
Print("&amp;&amp;" + " " + sL.GetByIndex(5) + " " + "&gt;=" + " " + sL.GetByIndex(4));
Print("&amp;&amp;" + " " + sL.GetByIndex(4) + " " + "&gt;=" + " " + sL.GetByIndex(3));
Print("&amp;&amp;" + " " + sL.GetByIndex(3) + " " + "&gt;=" + " " + sL.GetByIndex(2));
Print("&amp;&amp;" + " " + sL.GetByIndex(2) + " " + "&gt;=" + " " + sL.GetByIndex(1));
Print("&amp;&amp;" + " " + sL.GetByIndex(1) + " " + "&gt;=" + " " + sL.GetByIndex(0));
</code></pre>

<p>PRINT OUT RESULTS:</p>

<blockquote>
  <p>blue  >= red ;</p>
  
  <p>&amp;&amp; red  >= dodBlue ;</p>
  
  <p>&amp;&amp; dodBlue >= green ;</p>
  
  <p>&amp;&amp; green  >= yellow ;</p>
  
  <p>&amp;&amp; yellow  >= black ;</p>
  
  <p>&amp;&amp; black  >= cyan ;</p>
  
  <p>&amp;&amp; cyan  >= orange ;</p>
  
  <p>&amp;&amp; orange  >= white ;</p>
</blockquote>
