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