cocktail sort with three loops while for for