Sorts a [ ] in descending order using bubble sort .
static void sort ( ArrayList < Integer > a , int n ) { for ( int i = n ; i >= 0 ; i -- ) for ( int j = n ; j > n - i ; j -- ) if ( a . get ( j ) > a . get ( j - 1 ) ) { int tempswap = a . get ( j ) ; a . remove ( j ) ; a . add ( j , a . get ( j - 1 ) ) ; a . remove ( j - 1 ) ; a . add ( j - 1 , tempswap ) ; } print ( a , n ) ; }