You algorithm is using bubble sort which takes o(n^2). For larger input it might be slow. Why not use quick sort which will achieve the result you desire in O(nlogn)?
Here is some code, please note that it might be better to select the pivot as mid-element.
/**
* o(nlogn) - high probability otherwise o(n SQUARE)
*
*
* Choose a pivot value. We take the value of the middle element
* as pivot value, but it can be any value, which is in range of
* sorted values, even if it doesn't present in the array.
*
* Partition. Rearrange elements in such a way, that all elements
* which are lesser than the pivot go to the left part of the array
* and all elements greater than the pivot, go to the right part
* of the array. Values equal to the pivot can stay in any part
* of the array. Notice, that array may be divided in non-equal parts.
*
* Sort both parts. Apply quicksort algorithm recursively to the left
* and the right parts.
*
* @param input
*/
public void quickSort(int[] input, int start, int end){
if( start < end ){
int pindex = findParition(input, start, end);
quickSort(input, start, pindex-1);
quickSort(input, pindex+1, end);
}
}
/**
* findParition for quick sort
* @param input
* @param start
* @param end
* @return
*/
private int findParition(int[] input, int start, int end) {
int pivot = input[end];
int pindex = start;
for( int i = start; i < end; i++){
if( input[i] <= pivot ){
int temp = input[pindex];
input[pindex] = input[i];
input[i] = temp;
pindex++;
}
}
int temp = input[pindex];
input[pindex] = input[end];
input[end] = temp;
return pindex;
}