Working on graph sorting