Added a function to check if a list is already sorted or not