An implementation of slave sort in Python