Problem 30. Sort a list of complex numbers based on far they are from the origin.
Given a list of complex numbers z, return a list zSorted such that the numbers that are farthest from the origin (0+0i) appear first.
So if z is
z = [-4 6 3+4i 1+i 0]
then the output zSorted would be
zSorted = [6 3+4i -4 1+i 0]
Solution Stats
Problem Comments
-
5 Comments
Show
2 older comments
Muthu Annamalai
on 27 Feb 2013
It is useful to mention sort in 'descending' order of distance from origin.
Nicolas Licata
on 15 May 2017
hey
Rohan Lallbachan
on 5 Dec 2017
great problem!!!!
christopher Minix
on 24 Apr 2018
nice
Yash
on 4 Mar 2024
nice problem!
Solution Comments
Show commentsProblem Recent Solvers5777
Suggested Problems
-
Find the longest sequence of 1's in a binary sequence.
6630 Solvers
-
Given an unsigned integer x, find the largest y by rearranging the bits in x
1961 Solvers
-
2533 Solvers
-
5884 Solvers
-
10098 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!