import numpy as np np.random.seed(42) complex_numbers = np.random.random(5) + 1j * np.random.random(5) print "Complex numbers\n", complex_numbers print "Sorted\n", np.sort_complex(complex_numbers)