Sort Ancestral Names
Updated
Problem statement
Each entry in names has the form givenName romanNumeral, separated by one space. Sort the entries first by given name in ascending alphabetical order, then, for equal given names, by the Roman numeral’s numeric value in ascending order.
Return the original full strings in their sorted order, keeping each Roman spelling. For this exercise, assume the input array must remain unchanged.
Valid Roman numerals use I, V, X and L in standard notation: IV = 4, IX = 9 and XL = 40.
Function
sortRoman(names: String[]) → String[]Examples
Example 1
names = ["Louis IX","Louis VIII"]return = ["Louis VIII","Louis IX"]Both given names are Louis; 8 precedes 9.
Example 2
names = ["Philippe I","Philip II"]return = ["Philip II","Philippe I"]Philip alphabetically precedes Philippe, regardless of numeral values.
Example 3
names = ["Steven XL","Steven XVI","David IX","Mary XV","Mary XIII","Mary XX"]return = ["David IX","Mary XIII","Mary XV","Mary XX","Steven XVI","Steven XL"]Sort David, Mary, Steven, then each name’s numeric ordinal.
Constraints
1 <= names.length <= 50; every full entry is distinct.- Every entry contains exactly one space between the given name and numeral.
1 <= givenName.length <= 20; its first letter is uppercaseA-Zand any following letters are lowercasea-z.- Every Roman numeral is valid standard notation for an integer from
1through50, inclusive.
More Roblox Online Assessment questions
- Centered Block Placement QueriesOA · Seen Oct 2026
- Robot Navigation Around LasersOA · Seen Oct 2026
- Factory Batch Profit (Game Adaptation)OA · Seen Sep 2026
- Nested Recipe Blocks (Game Adaptation)OA · Seen Sep 2026
- Vehicle Builds for Required Terrain (Game Adaptation)OA · Seen Sep 2026
- Track Received Byte RangesOA · Seen Sep 2026
- Inventory Discount TrackerOA · Seen Sep 2026
- Break a PalindromeOA · Seen Jun 2026
- Count Pairs Differing in One DigitOA · Seen Oct 2025
- Find Zero Cells in a 2×2 GridOA · Seen Oct 2025
Similar questions at other companies
- Maximize Workday EarningsCitadel · OA · PHONE SCREEN · ONSITE INTERVIEWCitadel interview questions
- Frequently Bought TogetherAmazon · OA
- Aggregate Paginated Project Run RecordsReplit · OA
- Product Record SearchWells Fargo · OAWells Fargo interview questions
- Count User Mentions in Chat MessagesRamp · OARamp interview questions
- Word Frequency Counts in Alphabetical OrderAbridge · OAAbridge interview questions
- Top N Longest SentencesDeloitte · OADeloitte interview questions
- Sort Objects by a FieldZillow · OAZillow interview questions
- Rank Word-Translation Hints from Sentence TranslationsDuolingo · PHONE SCREEN · ONSITE INTERVIEWDuolingo interview questions
- Group AnagramsAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions