multiplicities, elements = zip(*group(multiset, False))