If I know the order of every element in a group, do I know the group? [duplicate]

Take $G=\mathbb{Z}/4\times \mathbb{Z}/4$, and $H=Q_8\times \mathbb{Z}/2$ of order $16$, where $Q_8$ denotes the quaternion group. Both groups have exactly $1$ element of order $1$, $3$ elements of order $2$ and $12$ elements of order $4$.

Edit: I understood the question as follows: Is there a counterexample where two groups $G$ and $H$ have the same number of elements for each order, but $G$ is not isomorphic to $H$ ? Is it really required, that all elements different from $1$ in $G$ have the same order ?


Here is an example with two groups of order $27$. Consider the group $G$ which is elementary abelian (all elements $x \in G$ satisfy $x^{3} = 1$), of order $27$. And then $H$ the non-abelian group of order $27$ and exponent $3$ (once more, $x^{3} = 1$ for all $x \in H$). Concretely, $$ \left\{\, \begin{bmatrix} 1 & a & b\\ 0 & 1 & c\\ 0 & 0 & 1 \end{bmatrix} : a, b, c \in F \,\right\}, $$ where $F = \mathbb{Z}/ 3 \mathbb{Z}$ is the field with three elements.