function I = sorti(A) [~, I] = sort(A); end f = @(A) sorti(sorti(A)) - 1; g = @(A) [A;f(A)]; g([1 100 10 10000 1000]) g([3 1 4 1 5 9 2]) g([0 1 0 1 0 1 0 1])
Standard input is empty
ans = 1 100 10 10000 1000 0 2 1 4 3 ans = 3 1 4 1 5 9 2 3 0 4 1 5 6 2 ans = 0 1 0 1 0 1 0 1 0 4 1 5 2 6 3 7