# Compare numeric words

• /*

• Problem 4:

Implement a function sort_numerically() that will receive a list of numbers represented in English words
and return the listed sorted by their numeric value, starting with the largest.

Input:

[
"seventy five",
"two hundred forty one",
"three thousand",
"one million thirty five thousand twelve",
"twenty",
"five hundred thousand",
"two hundred",
]

Output:

[
"one million thirty five thousand twelve",
"five hundred thousand"
"three thousand",
"two hundred forty one",
"two hundred",
"seventy five",
"twenty",
]
*/

• Nice question. But is this question similar to the question where given a number, you have to convert it to its English representation?

If you have the function `string convertToEnglish(int n)` implemented, then the rest becomes straightforward right?

• Hi, 1337,
I think, If you have the function string convertToEnglish(int n) implemented, then the rest becomes straightforward.
However, it can still be optimized, for example, one million is anyway larger than five hundred. so, maybe taking radix sort into consideration can induce better solution.

Thanks. Wish I can further discuss with you.
BTW: thanks for hosting such a good website...

• Thanks @sydy71, I got 'ya. You are correct, there's no need to implement the function `convertToEnglish`. I like this question and would love to add it to the library. Just wondering if you are interested in adding this question?

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.