added a sorting function, along with an algorith that builds each nodes logical equation

calls back earlier node equations for end node equations