input_list =[33,15,27,8,35,42,19,48] def selection_sort (input_list): size = len (input_list) for num in range (0,size- | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 1

input_list =[33,15,27,8,35,42,19,48] def selection_sort (input_list): size = len (input_list) for num in range (0,size-

Sort it in ascending order

6th Feb 2022, 11:33 AM
Akshaya Isaac
Akshaya Isaac - avatar
2 Respuestas
6th Feb 2022, 11:37 AM
Tibor Santa
Tibor Santa - avatar
0
You can use the built in sort() method which basically sorts any string of elements to alphabetically and it sorts any number element from ascending to descending and vice versa So input_list = [2,3,1] input_list.sort() print(input_list) Output = [1,2,3] To reverse input_list = [2,3,1] input_list.sort(reverse = True) print(input_list) Output : [3,2,1] Hope this helps, happy coding!
6th Feb 2022, 3:38 PM
Da GD Bot
Da GD Bot - avatar