As a school assignment, I have to create a Python app that allows the user to add personal information on X amount of people. With that said, the program allows the user to select many options and one of them is to sort the list of people with their infos alphabetically WITHOUT the use of sort() or quicksort() function whatsoever. The only thing left for me to do is to use the bubble sorting method.
Initially, I had the idea to create arrays for different data types like for example:
Last_names = [ ]
First_names = [ ]
Date_of_birth = [ ]
Gender = [ ]
but the thing is, if I apply bubble sort to Last_names, how would the other arrays info sync with the new order? Like are the infos on each person going to be mixed up?
Update:
so I decided to go with the format person1 = ["name1", "date_of_birth1", "gender1".....]
and then add that to another list
addressbook = ["person1", "person2", "person3", .....]
Instead of a list for each person I would used a dictionary. For example :
You can store the dictionaries directly into a list :
Record and their info can then be accessed this way :
For your sorting you can add a "key" parameter to your function and use that parameter to specify on which info you want to sort :
Note : Even if it is pretty simple and should work this is all untested code. Use with caution !