0

Where do I put sorted() to sort my record?

I need help in printing the Employee ID from 1 to 5 in order. But I don't know where to enter the sorted() command. Any help appreciated. Thanks. https://code.sololearn.com/c4hJYEoCnj0y/?ref=app

1st Dec 2019, 11:56 PM
Suman KG
Suman KG - avatar
2 Réponses
+ 4
if you have an unsorted list - let's call it list_ - then, instead of... for element in list_: ... ... you can write: for element in sorted(list_): ...
2nd Dec 2019, 1:04 AM
HonFu
HonFu - avatar
+ 1
ls = [5,3,4,1,2] print(sorted(ls))
2nd Dec 2019, 5:23 AM
Trigger
Trigger - avatar