Jan-11-2019, 09:17 PM
Converting List of 3 Element Tuple to Dictionary
Converting List of 3 Element Tuple to Dictionary
|
Jan-14-2019, 09:51 AM
Based on DeaD_EyE code we can build one-liner list comprehension that sorts both elements and list:
>>> data = [(1, 5, 1), (1, 3, 2), (1, 3, 1), (1, 1, 4)] >>> sorted([tuple(sorted(element)) for element in data]) [(1, 1, 3), (1, 1, 4), (1, 1, 5), (1, 2, 3)]
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame. |
|
Users browsing this thread: 1 Guest(s)