Created
December 17, 2022 13:24
-
-
Save thebigdatajedi/95ace520a27e54e597cfde1b74dd8ae5 to your computer and use it in GitHub Desktop.
Java, array sort done manually instead of using a builtin sort method.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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