I have a current algorithm for sorting my dictionary but it wont work if you compare 4 or more elements. What am I doing wrong?
database={
    0:['Ninna','Layug','201504584','09954895032','Quezon City','ninnalayug@gmail.com','18','02/21/1999'],
    1:['Yela','Gregorio','201506070','09984548540','UP Diliman','yelagregorio@gmail.com','19','04/18/1999'],
    2:['Denise','Gregorio','201506070','09984548540','UP Diliman','yelagregorio@gmail.com','19','04/18/1999'],
    3:['Alia','Layug','201504584','09954895032','Quezon City','ninnalayug@gmail.com','18','02/21/1999'],
    4:['Keeno','Layug','201504584','09954895032','Quezon City','ninnalayug@gmail.com','18','02/21/1999']
}
profiles=['0','1','2','3','4']
for x in range(len(profiles)):
    print(profiles)
    for j in range(len(profiles)-1-x):
        v1=database[j][0]
        v2=database[j+1][0]
        if v1>v2:
            sorted=False
            temp=profiles[j+1]
            profiles[j+1]=profiles[j]
            profiles[j]=temp
for x in profiles:
    print(database[int(x)][0],",",database[int(x)][1])
 
     
    