I'm starting with a list of strings. Each element contains a name and a Roman numeral. I want to sort this list alphabetically by name, and then by the Roman numeral.
I only managed to create a list with [name, numeral]
strings, so far:
names = ['Louis IX', 'Louis VIII', 'Maria III', 'Oscar IV', 'Adams XXX', 'Anuar III', 'Maria III', 'Oscar V']
def sortRoman(names):
names_separated = []
age_separated = []
for i in range(len(names)):
separated = names[i].split()
for j in range(len(separated)):
if j % 2 == 0:
names_separated.append(separated[j])
else:
age_separated.append(separated[j])
list_full_ordered = zip(names_separated, age_separated)
return list(sorted(list_full_ordered))
if __name__ == "__main__":
print(sortRoman(names))