Moved sorting and partition out of the constraint solver, started playing with some uninterpreted functions.