Java Function To Check If Array Is Sorted