title: Sort 4 numbers without array
body: <p>I have an exercise where I need to put 4 numbers in ascending order and then descending <strong>without using arrays</strong>. I can only use loops and if statements. I've done it with 3 numbers, but now with 4 numbers I am unable to think of the logic.</p>
  
  <pre><code>  float great1 = 0, great2 = 0, great3 = 0, great4 = 0;
    int a = 7, b = 5, c = 6, d = 0;
  
    // Descending
    if (a &gt; b &amp;&amp; b &gt; c) {
      great1 = a;
      great2 = b;
      great3 = c;
  
    } else if (a &gt; b &amp;&amp; b &lt; c) {
      great1 = a;
      great2 = c;
      great3 = b;
  
    } else if (b &gt; a &amp;&amp; a &gt; c) {
      great1 = b;
      great2 = a;
      great3 = c;
  
    } else if (b &gt; a &amp;&amp; a &lt; c) {
      great1 = b;
      great2 = c;
      great3 = a;
  
    } else if (c &gt; a &amp;&amp; a &gt; b) {
      great1 = c;
      great2 = a;
      great3 = b;
    }
  
    else {
      great1 = c;
      great2 = b;
      great3 = a;
    }
  </code></pre>