Skip to content

Instantly share code, notes, and snippets.

@TwiN
Created March 26, 2016 23:02
Show Gist options
  • Save TwiN/77313954e2afb1fe2024 to your computer and use it in GitHub Desktop.
Save TwiN/77313954e2afb1fe2024 to your computer and use it in GitHub Desktop.
Java quick sort
public static void quickSort(int myList[], int left, int right) {
int temp, i = left, j = right;
int pivot = myList[(left+right)/2];
do {
while(myList[i] < pivot) i++;
while(pivot < myList[j]) j--;
if (i <= j) {
temp = myList[i];
myList[i] = myList[j];
myList[j] = temp;
i++;
j--;
}
} while (i <= j);
if (left<j) quickSort(myList, left, j);
if (i<right) quickSort(myList, i, right);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment