Sorting escape rules to ensure an apply order.