4
I have a college exercise, but I need some help. I need to do a program that gets a list containing N nomes
and returns a list of all received names sorted by size (number of letters) the Selection Sort. In case you have two nomes
of the same size, the ordering of these two should be alphabetical increasing. I cannot use the function sort
.
I did the first part of sorting by the size of the string:
def nome_ordena(nomes):
for i in range(len(nomes)):
i_menor = i
for j in range(i+1, len(nomes)):
if len(nomes[i_menor]) > len(nomes[j]):
i_menor= j
nomes[i], nomes[i_menor] = nomes[i_menor], nomes[i]
return nomes
I have tried in many ways to alphabetize those that are the same size, but I’m not getting it. Can someone help me?