add sort to trippatterns before shape