Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- public class CW040121 {
- public static void main(String[] args) {
- int[] intArray = {1,12,4,32,8,7,9,11};
- Sort(intArray);
- }
- public static void Sort(int[] intArray){
- int temp = 0;
- for (int i = 0; i <intArray.length; i++) {
- for (int j = i+1; j <intArray.length; j++) {
- if(intArray[i] >intArray[j]) { //swap elements if not in order
- temp = intArray[i];
- intArray[i] = intArray[j];
- intArray[j] = temp;
- }
- }
- }
- System.out.println(Arrays.toString(intArray));
- }
- }
Add Comment
Please, Sign In to add comment