now sorts all nodes with edges.