Yo no veo el orden | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Yo no veo el orden

dice que la lista está ordenada, pero no cual es el parámetro, es decir, si es alfabeto u otro orden

19th Aug 2018, 4:18 PM
Javier Amores Ruiz
Javier Amores Ruiz - avatar
5 Answers
+ 1
Los enteros y las cadenas se organizarán en una nueva lista con el método ordenado (). Además, ordenado (reverse = True) organizará la nueva lista al revés. También hay una función .sort (), pero esto muta la lista actual y no crea un nuevo objeto. La gran pregunta es, ¿cuál es más eficiente? ... Aquí es donde "timeit ()" ayudará a determinar la eficiencia. ''' alpha = ['a', 'z', 'b', 'v', 'c', 'd', 'm'] num = [9,4,2,0,6,5,1] imprimir (ordenado (alfa)) imprimir (ordenado (num)) '''
19th Aug 2018, 4:37 PM
Steven M
Steven M - avatar
+ 1
Gracias
19th Aug 2018, 4:38 PM
Javier Amores Ruiz
Javier Amores Ruiz - avatar
0
Integers and strings will be arranged in a new list with the sorted() method. Also, sorted(reverse=True) will arrange the new list backwards. There is also a .sort() function, but this mutates the current list and does not create a new object. The big question is which is more efficient?... This is where "timeit()" will help determine efficiency. ''' alpha=['a', 'z', 'b', 'v', 'c', 'd', 'm'] num=[9,4,2,0,6,5,1] print(sorted(alpha)) print(sorted(num)) '''
19th Aug 2018, 4:27 PM
Steven M
Steven M - avatar
0
disculpa pero si no me lo traduce no entiendo la respuesta. Gracias
19th Aug 2018, 4:30 PM
Javier Amores Ruiz
Javier Amores Ruiz - avatar
0
lo siento, mi espanol es malo y esto es google translate
19th Aug 2018, 4:41 PM
Steven M
Steven M - avatar