sortable iterators for Python
Decorate your generator function with
@sortable_iterator and you’ll be able to use the function as a key in
sorted. It’ll only look as far ahead in each iterator as it needs to in order to sort the input array — useful if the operations for generating sort key components would otherwise use a lot of computer time or memory.