Hello everyone, I'm new to the python forum and I need help about ending my python program.
My goal is to sort a built-in list by date of birth of the person from oldest to youngest.
Once this sorting is done, I then add the names and first names in relation of course...
I tried several things, but unfortunately I only managed to do it by using the person's age ("example: 18 years" but I didn't manage to do it for "18/06/1989").
I would like to do this without using a sort function.
So i don't want to reproduce the use of sort function..
The goal is ultimately to make this sorting by calling a function and the return is supposed to be of this type.
WILSON MIKE 26/06/1950
EMERIC JAMES 27/06/1960
MOPAL ARTHUR 27/06/1966
At the moment I have been able to do it only with the age of the form "66" and not "26/06/1966" of the person as well as with the use of sorting...
My goal is to sort a built-in list by date of birth of the person from oldest to youngest.
Once this sorting is done, I then add the names and first names in relation of course...
I tried several things, but unfortunately I only managed to do it by using the person's age ("example: 18 years" but I didn't manage to do it for "18/06/1989").
I would like to do this without using a sort function.
So i don't want to reproduce the use of sort function..
The goal is ultimately to make this sorting by calling a function and the return is supposed to be of this type.
WILSON MIKE 26/06/1950
EMERIC JAMES 27/06/1960
MOPAL ARTHUR 27/06/1966
At the moment I have been able to do it only with the age of the form "66" and not "26/06/1966" of the person as well as with the use of sorting...
listepersonnes = [['WILSON', 'MIKE', 'H', '68'], ['EMERIC', 'JAMES', 'H', '58'], ['MOPAL', 'ARTHUR', 'H', '52']] def agepersonne(): print(sorted([i[:4] for i in listepersonnes], key=lambda x: x[3], reverse = True)) agepersonne()Result is :
WILSON MIKE 68 EMERIC JAMES 58 MOPAL ARTHUR 52My new list of persons should be like this :
listepersonnes = [['WILSON', 'MIKE', 'H', '26/06/1950'], ['EMERIC', 'JAMES', 'H', '27/06/1960'], ['MOPAL', 'ARTHUR', 'H', '27/06/1966']]Thanks for all !