I would like to sort royal names. First Preference to the alphabet. If both names are same then I would like to sort by the roman numeral. For Example if input is : King III, King II, Queen IX. (as 1st 2 strings are same they need to be sorted by their appended roman numeral) So Expected output : King II, King III, Queen IX.
I tried storing roman numerals in a hashmap and writing a function that replaces roman numerals in given array to King 2, King 3, Queen 9 and then tried sorting but was not able to implement correctly. Could anyone kindly help me with this?