Problem 94. Target sorting
Sort the given list of numbers a according to how far away each element is from the target value t. The result should return the list sorted in descending order of the absolute value of the difference between a(n) and t.
So if a = [1 2 4 8 17] and t = 12, then the output b should be [1 2 4 17 8].
Solution Stats
Problem Comments
-
5 Comments
Show
2 older comments
YUANYU YANG
on 27 Mar 2015
a nice practice.
Akash Srivastav
on 24 May 2018
I don't why this easy problem come at last.
Ajay Pattassery
on 21 Feb 2019
Good one.
Solution Comments
Show commentsProblem Recent Solvers4442
Suggested Problems
-
First non-zero element in each column
841 Solvers
-
Back to basics 17 - white space
269 Solvers
-
Determine Whether an array is empty
768 Solvers
-
Find a subset that divides the vector into equal halves
386 Solvers
-
1589 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!