generating the ops in sorted order