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
-
Make the vector [1 2 3 4 5 6 7 8 9 10]
53967 Solvers
-
Extract leading non-zero digit
2258 Solvers
-
Volume of a sphere given its surface area
156 Solvers
-
Fahrenheit to Celsius converter
612 Solvers
-
The sum of the numbers in the vector
650 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!