Sort group before logging to make it easy to assert in tests.

Fix #50