def trocar(vals, posX, posY):
temp = vals[posX]
vals[posX] = vals[posY]
vals[posY] = temp
return None
def rearranjar_tupla(tupla):
return tupla[::-1]
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)
ZGVmIHRyb2Nhcih2YWxzLCBwb3NYLCBwb3NZKToKICAgIHRlbXAgPSB2YWxzW3Bvc1hdCiAgICB2YWxzW3Bvc1hdID0gdmFsc1twb3NZXQogICAgdmFsc1twb3NZXSA9IHRlbXAKICAgIHJldHVybiBOb25lCgpkZWYgcmVhcnJhbmphcl90dXBsYSh0dXBsYSk6CiAgICByZXR1cm4gdHVwbGFbOjotMV0KICAgIApkZWYgb3JkZW5hcih2YWxvcmVzKToKICAgIHRhbWFuaG8gPSBsZW4odmFsb3JlcykgLSAxCiAgICB0cm9xdWVpID0gVHJ1ZQogICAgd2hpbGUgdHJvcXVlaToKICAgICAgIHRyb3F1ZWkgPSBGYWxzZQogICAgICAgZm9yIGkgaW4gcmFuZ2UodGFtYW5obyk6CiAgICAgICAgICBpZiByZWFycmFuamFyX3R1cGxhKHZhbG9yZXNbaV0pID4gcmVhcnJhbmphcl90dXBsYSh2YWxvcmVzW2kgKyAxXSk6CiAgICAgICAgICAgIHRyb2Nhcih2YWxvcmVzLCBpLCBpICsgMSkKICAgICAgICAgICAgdHJvcXVlaSA9IFRydWUKICAgIHRhbWFuaG8gLT0gMQogICAgcmV0dXJuIHZhbG9yZXMKCgpsaXN0YT0gWygnQW5hJywgMzAsIDYuNjkpLCAoJ0pvw6NvJywgMjUsIDYuMTEpLCAoJ1BlZHJvJywgMzAsIDYuNjkpLCAoJ01hcmlhJywgMjgsIDUuNDUpLCAoJ1RoaWFnbycsIDQwLCA1LjQ1KSwgKCdSYXF1ZWwnLCAyNiwgMTAuMCldCgp4PW9yZGVuYXIobGlzdGEpCnByaW50KHgpCg==
[('Maria', 28, 5.45), ('Thiago', 40, 5.45), ('João', 25, 6.11), ('Ana', 30, 6.69), ('Pedro', 30, 6.69), ('Raquel', 26, 10.0)]