combined pivot and sort into nest by