sorts triplets for derivative and integral just to be safe