Commit 682f56a6 authored by Samadhi Ranasinghe's avatar Samadhi Ranasinghe

Commit 5

parent c199a953
#python app.py
# gender age job
values = [
{'name':"user1",'key':26,'gender':"F",'job':"IT"},
{'name':"user2",'key':28,'gender':"F",'job':"HR"},
{'name':"user3",'key':32,'gender':"M",'job':"IT"},
{'name':"user4",'key':27,'gender':"F",'job':"Engineer"},
{'name':"user5",'key':34,'gender':"M",'job':"HR"},
{'name':"user6",'key':38,'gender':"F",'job':"IT"},
{'name':"user7",'key':25,'gender':"M",'job':"Engineer"}
]
sorted_values = sorted(values, key=lambda x:x['key'])
#print(sorted_values)
arr_30 = []
arr_40 = []
arr_50 = []
arr_60 = []
final_arr = []
for val in sorted_values:
if(val['key'] < 30):
arr_30.append(val)
elif(val['key'] >= 30 and val['key']<40):
arr_40.append(val)
if(val['key'] >= 40 and val['key']<50):
arr_50.append(val)
elif(val['key'] >= 50 and val['key']<60):
arr_60.append(val)
sorted_values_30 = sorted(arr_30, key=lambda x:(x['key'],x['gender']))
sorted_values_40 = sorted(arr_40, key=lambda x:(x['key'],x['gender']))
sorted_values_50 = sorted(arr_50, key=lambda x:(x['key'],x['gender']))
sorted_values_60 = sorted(arr_60, key=lambda x:(x['key'],x['gender']))
for i in sorted_values_30:
final_arr.append(i)
for i in sorted_values_40:
final_arr.append(i)
for i in sorted_values_50:
final_arr.append(i)
for i in sorted_values_60:
final_arr.append(i)
print("First List")
print("=========================================")
print(values)
print("=========================================")
print("Final List")
print("=========================================")
print(final_arr)
print("=========================================")
print("SEAT NO")
print("seat 01 : "+str(final_arr[0]))
print("seat 02 : "+str(final_arr[1]))
print("seat 03 : "+str(final_arr[2]))
print("seat 04 : "+str(final_arr[3]))
print("seat 05 : "+str(final_arr[4]))
print("seat 06 : "+str(final_arr[5]))
print("seat 07 : "+str(final_arr[6]))
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment