i know there are lots of codes about this but i tried to write my own.

what is wrong with that?

Code :

public static void sortingArrays( int[] a){ int k = 0; int index = a[0]; int[] a2 = new int[a.length]; for(int i=0; i<a.length; i++){ for(int j=0; j<a.length; j++){ if ( a[j] > index ){ index = a[j]; k=j;} } a[k] = 0; a2[i] = index; System.out.print(a2[i]); } }