sort graphs