Added correct sorting in groups - always append to the last one.