In this code I created a function to sort a vector from smallest to largest. It works when the vector has odd number of elements but not when it is even. Here's the code:
function[r] =vecsort(n)r=zeros(size(n));for i=1:n[a,b]=min(n);r(i)=a;n=n([1:b-1 b+1:end]);endend
Best Answer