title: Bubble Sort not sorting correctly - Java
body: <p>I've been trying to get a simple Bubble Sort method in Java to work and I cannot see the problem why it is not working. I want the lowest element in the array to be the first and the highest the last. Here I gave the method the already sorted array with values <code>[1, 2, 3, 4]</code>. </p>
  
  <p>The output is an array <code>[1, 3, 2, 4]</code> - so it sorted something although it should not. Does anybody see the problem? </p>
  
  <pre><code>import java.util.Arrays;
  
  public class BubbleSort {
      public static int [] bubblesortMethode(int sortMe[])
      {
          int nrOfSwaps = 0;
  
          for (int i = 0; i &lt; sortMe.length - 1; i++)  {
              for (int j = 1; j &lt; sortMe.length; j++) {
                  if(sortMe[i] &gt; sortMe[j]){
                      int temp  = sortMe[j];
                      sortMe[j] = sortMe[i];
                      sortMe[i] = temp;
                  }
              }
              nrOfSwaps++;
          }
          System.out.println("Number of swaps" + " " + nrOfSwaps);
          return sortMe;
      }
  
      public static void main (String[] args) {
          int sortMe [] = {1,2,3,4};
          System.out.println(Arrays.toString(bubblesortMethode(sortMe)));
      }
  }
  </code></pre>