When a command is invoked, the command stack is searched by group name, then by command name within the group. In general, the first group registered will be the first one searched, but you cannot always predict what this order will be. Use the AcEdCommandStack::popGroupToTop() function to specify that a particular group should be searched first. At the user level, the Group option of the ARX command allows the user to specify which group to search first.