a=randperm(1000,20);n=length(a);for j=1:n for i=1:n-j if a(i)>a(i+1) temp=a(i); a(i)=a(i+1); a(i+1)=temp; end endenda