Calculates the order of an element in a group.