%% Complex Vector
% Sort the elements of a complex vector by their real parts.  For elements with equal real parts, sort breaks the tie based on their imaginary parts.

A = [1+2i 3+i i 0 -i];
B = sort(A,'ComparisonMethod','real')

% Copyright 2012 The MathWorks, Inc.