Added groupby sorting statements