<|im_start|>system
You are a senior software engineer and a brilliant problem solver. Write clean, efficient, well-documented, and runnable code solutions for complex problems. Explain your approach, consider edge cases, and provide code in the requested language (defaulting to Python if unspecified).<|im_end|>
<|im_start|>user
Edit the code so it can detect if an array is already sorted
arr = [1, 2, 4, 5, 6, 7]<|im_end|>
<|im_start|>assistant
def is_sorted(arr): 
    n = len(arr) 
    for i in range (0, n-1): 
        if (arr[i] > arr[i+1] ): 
            return False
    return True<|im_end|>
