added two docstrings and provided cmp_to_key for python3-compatibility