function v=chksrt(A)         % v=1 if sorted     
  n=length(A);               % v=0 if not sorted 
  for k =1:(n-1)
    if A(k )> A(k +1)
       v=0;
       return;
    end
  end
  v=1;
end
