Closes #3: sort rules in order they are applied