cocktailsort java implementation