I have a file.txt with the following:
('sim', 'sim','03-01-19', 'sim','Fechada', 'sim')
('ano', 'a', '02-01-19', 'a', 'Aberta', 'a')
('pano', 's', '01-01-19', 's', 'Aberta', 's')
I would like to sort it like this:
('ano', 'a', '02-01-19', 'a', 'Aberta', 'a')
('pano', 's', '01-01-19', 's', 'Aberta', 's')
('sim', 'sim','03-01-19', 'sim','Fechada', 'sim')
also sort it by the date like this:
('pano', 's', '01-01-19', 's', 'Aberta', 's')
('ano', 'a', '02-01-19', 'a', 'Aberta', 'a')
('sim', 'sim','03-01-19', 'sim','Fechada', 'sim')
If anyone could help me with that i would be very grateful :)
Sry for my bad English
def ordenar():
ficheirocompra = open("compras.txt","r")
lines = ficheirocompra.readlines()
for line in lines:
a = line[0:line.find(',')]
print(a.sort())
ficheirocompra.close()