function [ res ] = isunsorted( V )
%ISUNSORTED returns 0 if V is sorted in ascending order
%   and the index of the first element that is greater than its next
%   otherwise
%   Minas Spetsakis, Nov. 2017

N=length(V); % Could use size(V,1) but there is a little catch there.

for i=1:N-1
    if V(i)>V(i+1)
        res=i;
        return;
    end
end
res=0;
end
