Add order_graph_by_groups funtion