modified the __init__ method so that it sorts the variables before sorting into self.rules.