← Questions

Sort names by text prefix, then numeric suffix

0
PerplexityCodingLast asked Oct 2026

You get a list of topic names, each a lowercase word, an underscore and a number, such as logs_10 or logs_2. Sort them by the word first and, for the same word, by the number as an integer, so logs_2 comes before logs_10. Keep duplicates. Explain why a plain string sort gets this wrong and what key you sort by.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding