public class Ass { int [] array ; public static void swap(int [] x) { for (int i = 0 ; i<x.length ; i++){ int b =0 ; for (int j = 0 ; j<x.length ; j++){ if ( x[i] > x[j] ) { b ++ ; } } if (b!=0) { int temp = x[i] ; x[i] = x[b] ; x[b] = temp ; } } } public static void main (String [] args) { array = new int [] {1,4,5,7,3,0,8} ; Ass.swap(array) ; for (int i = 0 ; i<array.length ; i++) ; System.out.println(array[i]) ; } }