fix rule sorting