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
-
Find the longest sequence of 1's in a binary sequence.
6815 Solvers
-
Calculate the Levenshtein distance between two strings
1512 Solvers
-
Project Euler: Problem 4, Palindromic numbers
1293 Solvers
-
Back to basics 9 - Indexed References
463 Solvers
-
Find the sides of an isosceles triangle when given its area and height from its base to apex
2213 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!