Fill This Form To Receive Instant Help
Homework answers / question archive / Create a function leadingSort whose job is sorting a passed-in array differently by their highest or leading place value
Create a function leadingSort whose job is sorting a passed-in array differently by their highest or leading place value. We will look at the highest place value digit and use that to order the numbers if 2 numbers have the same place value look to the next number and so on until there is a difference. Nothing special needs to be done if the numbers are duplicates:
input: {78, 4, 177, 7, 14, 33, 350124, 173, 871, 90, 1122}
output: {1122, 14, 173, 177, 33, 350124, 4, 7, 78, 871, 90}
Note that 7 comes before 78 since nothing is smaller than the 8