added ordering with stats pivots

fix for #1065