sort groups on magic