Conventional ascending order of one digit number is [ 0, 1, 2, ......9]. Now this order is changed and stored in vector a. For example in a vector a = [3 8 7 5 0 9 2 1 6 4], first element 3 denotes the lowest value equal to 0 like in conventional representation and last element 4 denotes the highest value equal to 9 in conventional representation. Another vector b is unsorted one. You need to sort the vector b according the new order expressed by vector a. For a given vector b =[ 2 4 5 5 3 3 3 9 0] the sorted sequence is [3 3 3 5 5 0 9 2 4] and which should be stored in another vector named c.
Example : a= [ 3 8 7 5 0 9 2 1 6 4] % In this order '3' is considered as the smallest number and '4' is considered as largest number. b= [ 2 4 5 5 3 3 3 9 0] % This sequence is to be sorted according to the order in 'a'.
therefore, The should be, c=[3 3 3 5 5 0 9 2 4]
Comment: Consider both a & b are made using the digits from 0 to 9 only
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers23
Suggested Problems
-
Check if number exists in vector
14325 Solvers
-
Who has power to do everything in this world?
488 Solvers
-
Solving Quadratic Equations (Version 1)
506 Solvers
-
Deleting an element in a matrix
495 Solvers
-
Return fibonacci sequence do not use loop and condition
870 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!