You own a lot of guitars, and each guitar has a unique serial number. You want to be able to look up serial numbers quickly, so you decide to sort the entire list as follows.
Each serial number consists of uppercase letters ('A' - 'Z') and digits ('0' - '9'). To see if serial number A comes before serial number B, use the following steps:
- If A and B have a different length, the one with the shortest length comes first.
- Else if sum_of_digits(A) differs from sum_of_digits(B) (where sum_of_digits(X) returns the sum of all digits in string X), the one with the lowest sum comes first.
- Else compare them alphabetically, where digits come before letters.
Given a String[] serialNumbers, return a String[] with the ordered list of serial numbers in increasing order. |