Target sorting - MATLAB Cody - MATLAB Central

Problem 94. Target sorting

Difficulty:Rate

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

53.8% Correct | 46.2% Incorrect
Last Solution submitted on Feb 24, 2025

Problem Comments

Solution Comments

Show comments
Primes and Rough Numbers, Basic ideas
What is a rough number? What can they be used...
2
3

Problem Recent Solvers4509

Suggested Problems

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!
Go to top of page