Ad
  • Custom User Avatar

    Try console.log(originArr) and see the intermediate result of your array before sorting takes place. Note that the given string can be empty.

    Also, your code does not meet this criteria:

    When two numbers have the same "weight", let us class them as if they were strings (alphabetical ordering) and not numbers:
    
    180 is before 90 since, having the same "weight" (9), it comes before as a string.