title: MASM x86 How to sort an array in ascending order?
body: <p>I have managed to successfully sort my array in descending order, but I'm a bit confused about how to sort it into ascending order as well.</p>
  <p>I basically want to sort my array into ascending order as well, but I'm kind of stuck. I don't know if I'm overthinking it or not, but I've run into a big roadblock for such a simple problem.</p>
  <p>Here's what I have coded for sorting my array of random numbers into descending order:</p>
  <p>&quot;&quot;&quot;
  sortList PROC</p>
  <pre><code>push    ebp
  mov     ebp, esp
  mov     ecx, [ebp + 8]      
  mov     esi, [ebp + 12]     
  dec     ecx                 
  
  
  outer_loop:
      
      
      mov     eax, [esi]
      mov     edx, esi        
      push    ecx
  
      
      inner_loop:
          
          
          mov     ebx, [esi + 4]          
          mov     eax, [edx]              
          cmp     eax, ebx
  
          
          jge     do_not_swap
  
          ;Else, push parameters and swap
          add     esi, 4
          push    esi
          push    edx
          push    ecx
          call    exchange
          sub     esi, 4
  
          do_not_swap:
          add     esi, 4
          loop    inner_loop
  
      ;End the inner loop and restore outer loop stuff
      pop     ecx
      mov     esi, edx
      add     esi, 4
      loop    outer_loop
  
  
  pop     ebp         
  ret     8
  </code></pre>
  <p>sortList ENDP
  &quot;&quot;&quot;</p>
  <p>Any help is greatly appreciated!</p>
  <p>Thanks so much for your time.</p>