def trocar(vals, posX, posY):
temp = vals[posX]
vals[posX] = vals[posY]
vals[posY] = temp
return None
def rearranjar_tupla(tupla):
return (-tupla[2], tupla[1], tupla[0])
def ordenar(valores):
tamanho = len(valores) - 1
troquei = True
while troquei:
troquei = False
for i in range(tamanho):
if rearranjar_tupla(valores[i]) > rearranjar_tupla(valores[i + 1]):
trocar(valores, i, i + 1)
troquei = True
tamanho -= 1
return valores
lista= [('Ana', 30, 6.69), ('João', 25, 6.11), ('Pedro', 30, 6.69), ('Maria', 28, 5.45), ('Thiago', 40, 5.45), ('Raquel', 26, 10.0)]
x=ordenar(lista)
print(x)
ZGVmIHRyb2Nhcih2YWxzLCBwb3NYLCBwb3NZKToKICAgIHRlbXAgPSB2YWxzW3Bvc1hdCiAgICB2YWxzW3Bvc1hdID0gdmFsc1twb3NZXQogICAgdmFsc1twb3NZXSA9IHRlbXAKICAgIHJldHVybiBOb25lCgpkZWYgcmVhcnJhbmphcl90dXBsYSh0dXBsYSk6CiAgICByZXR1cm4gKC10dXBsYVsyXSwgdHVwbGFbMV0sIHR1cGxhWzBdKQogICAgCmRlZiBvcmRlbmFyKHZhbG9yZXMpOgogICAgdGFtYW5obyA9IGxlbih2YWxvcmVzKSAtIDEKICAgIHRyb3F1ZWkgPSBUcnVlCiAgICB3aGlsZSB0cm9xdWVpOgogICAgICAgdHJvcXVlaSA9IEZhbHNlCiAgICAgICBmb3IgaSBpbiByYW5nZSh0YW1hbmhvKToKICAgICAgICAgIGlmIHJlYXJyYW5qYXJfdHVwbGEodmFsb3Jlc1tpXSkgPiByZWFycmFuamFyX3R1cGxhKHZhbG9yZXNbaSArIDFdKToKICAgICAgICAgICAgdHJvY2FyKHZhbG9yZXMsIGksIGkgKyAxKQogICAgICAgICAgICB0cm9xdWVpID0gVHJ1ZQogICAgdGFtYW5obyAtPSAxCiAgICByZXR1cm4gdmFsb3JlcwoKCmxpc3RhPSBbKCdBbmEnLCAzMCwgNi42OSksICgnSm/Do28nLCAyNSwgNi4xMSksICgnUGVkcm8nLCAzMCwgNi42OSksICgnTWFyaWEnLCAyOCwgNS40NSksICgnVGhpYWdvJywgNDAsIDUuNDUpLCAoJ1JhcXVlbCcsIDI2LCAxMC4wKV0KCng9b3JkZW5hcihsaXN0YSkKcHJpbnQoeCkK
[('Raquel', 26, 10.0), ('Ana', 30, 6.69), ('Pedro', 30, 6.69), ('João', 25, 6.11), ('Maria', 28, 5.45), ('Thiago', 40, 5.45)]