Sort on client instead of server for grouped aggregation to fix issue #417