Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from operator import itemgetter
- empleados = [
- {'id': 1003, 'nombre': 'Angela', 'apellido': 'Romero'},
- {'id': 1002, 'nombre': 'Andrea', 'apellido': 'Ruiz'},
- {'id': 1004, 'nombre': 'Edward', 'apellido': 'Ortiz'},
- {'id': 1001, 'nombre': 'Javier', 'apellido': 'Meneses'}
- ]
- print(sorted(empleados, key = itemgetter('nombre')))
- print(end='\n')
- print(sorted(empleados, key = itemgetter('id')))
- print(end='\n')
- print(sorted(empleados, key = itemgetter('apellido', 'nombre')))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement