Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
240
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2022-240
240
Commits
118899b6
Commit
118899b6
authored
May 14, 2022
by
Samadhi Ranasinghe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit 2
parent
f2f985c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
0 deletions
+67
-0
Commit_2.py
Commit_2.py
+67
-0
No files found.
Commit_2.py
0 → 100644
View file @
118899b6
#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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment