example to check if array is sorted