Handling better the rewrite sort with left hand side function.