Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thebigdatajedi/95ace520a27e54e597cfde1b74dd8ae5 to your computer and use it in GitHub Desktop.
Save thebigdatajedi/95ace520a27e54e597cfde1b74dd8ae5 to your computer and use it in GitHub Desktop.
Java, array sort done manually instead of using a builtin sort method.
//Outer loop
for (int i = 0; i < nums.length; i++ ) {
//inner loop
for(int j = i + 1; j < nums.length; j++){
int temp = 0;
if(nums[j] < nums[i]) {
//checking elements
temp = nums[i];
nums[i] = nums[j];
nums[j] = temp;
}
}
}
return nums;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment