Refactored Equations._sort_static_equations into utils.topsort