Finished is_sorted function, for testing whether a range is sorted.