Replace sort function for p3.3 compatible and fix exec statement