public static boolean isSorted ( char [ ] charArray ) { for ( int i = 0 ; i < charArray . length - 1 ; i ++ ) { if ( charArray [ i ] > charArray [ i + 1 ] ) { return false ; } } return true ; }
Check if the char array is sorted . It loops through the entire char array once checking that the elements are sorted .