Class sort
-
[Python] - Sort / Reverse개발/Python 2022. 7. 27. 15:26
1. Sort Only List(In-place) Reverse = [::-1] a = [1,5,2,4] a.sort() > [1,2,4,5] # a.sort() -> a[::-1] a.sort(reverse=True) > [5,4,2,1] 2. Sorted Use Iterable Object A simple ascending sort and returns a new sorted list key parameter call function for list element #iterable dict temp = {1: 'D', 2: 'B', 3: 'B', 4: 'E', 5: 'A'} sorted(temp) > [1, 2, 3, 4, 5] sorted(temp.items()) > [(1, 'D'), (2, 'B..