zipsort¶
- emlib.misc.zipsort(a, b, key=None, reverse=False)[source]¶
Sort a and keep b in sync
It is the equivalent of:
a, b = unzip(sorted(zip(a, b), key=key))
- Return type:
tuple[list[TypeVar(T)],list[TypeVar(T2)]]
Example
>>> names = ['John', 'Mary', 'Nick'] >>> ages = [20, 10, 34] >>> ages, names = zipsort(ages, names) >>> names ('Mary', 'John', 'Nick')