Factor key-value sorter out into PyOpenCL.