Fixed sorting for graph.