sort rules by priority