sort first n element of array
<p>I know how to sort an array by ascending order, but not quite catch it when just sort first n (in my case, 4) elements. I tried to add a count value and do-while loop but it still sort all the element. Any idea?</p>

<pre><code>    do{

        for(i=0; i&lt;size; i++){
            for(j=i+1; j&lt;size; j++){
                if(arr[j] &lt; arr[i]){
                    temp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = temp;
                    count++;
                }
            }
        }
      }while(count&lt;5)
</code></pre>