sort graphs by key