title: Incrementing at j even though it doesn't meet the condition
body: <pre class="lang-java prettyprint-override"><code>public class sorting {
    public static void sort(int arr[])     {
          int n = arr.length;
          int count = 0;
          int tempArr [] = arr.clone();
   
          // One by one move boundary of unsorted subarray
          for (int i = 0; i &lt; n-1; i++){
              // compare proceeding element
              int val = i;
              for (int j = 0; j &lt; n; j++){
                  if (arr[val] &gt; arr[j])
                      count++;
                      System.out.println(count);
              }
              tempArr[count] = arr[val];
              count = 0;//reset counter
          }
        for (int i = 0; i &lt; n; ++i)
              System.out.print(tempArr[i] + &quot; &quot;);
      }
     public static void main(String args[]) {
       
     int a[] = {50, 40, 30, 20, 10};
     sort(a);
     }
  }
  </code></pre>
  <p>I assume that this would sort the arrays in another array, but there is a problem where index 0 won't change. This uses a method of comparing the current value to all the elements in the array. Then using count as the index by incrementing it if the current key is greater than the proceeding values.</p>
  <p>The problem is that it increments at the last part.</p>
  <pre class="lang-none prettyprint-override"><code>0
  1
  2
  3
  4
  0
  0
  1
  2
  3
  0
  0
  0
  1
  2
  0
  0
  0
  0
  1  //it incremented 
  50 20 30 40 50 
  
  </code></pre>