Linear algebra of finite abelian groups If $f: V \to W$ is a surjective homomorphism of vector spaces, and we have fixed a basis for $V$, it is always possible to find a basis for $W$ such that the matrix associated to $\phi$ in the two bases is triangular with ones on the "diagonal" (what I mean with this is explained more precisely later, in the case of abelian groups), up to possibly permuting the chosen basis of $V$. This motivates the following question, in the realm of finite abelian groups.
Let $H$ be a finite abelian group with a fixed basis $h_1, \ldots, h_n$, with "basis" here we mean elements that satisfy the property $\langle h_1 \rangle \oplus \ldots \oplus \langle h_n \rangle=H$. Let $\phi:H \to G$ be a homomorphism of finite abelian groups. Let us assume that $\phi$ is surjective, so $\phi(h_1), \ldots, \phi(h_n)$ generate $G$.
Is it possible to find a basis for $G$, and a permutation of the elements $h_1, \ldots, h_n$, such that the matrix associated with $\phi$ in the two given basis has a triangular form with $1$ on the diagonal? 
More precisely, can we find a basis $g_1, \ldots, g_m$ for $G$, with $m \leq n$, and a permutation $\sigma \in \mathfrak{S}_n$ such that we can write 
$\phi(h_{\sigma(i)}) = a_{i,1} g_1 + \ldots+ a_{i,m} g_m$
with $a_{i,j}=0$ when $j>i$, and $a_{i,i}=1$?
(I asked a similar question on math.stackexchange, but I spelled it differently and in a silly/wrong way so that the answer in that case was trivial)
 A: I think I can prove this in the case when $G$ is a $p$-group. Assume $\phi(h_1), \ldots, \phi(h_m)$ are irredundant generators: if any of them is removed they are no longer a generating set for $G$. There must be an element of maximal order, and assume after possibly permuting that it is $\phi(h_1)$. Then the cyclic group generated by $\phi(h_1)$ is a direct summand of $G$, thus we can take $\phi(h_1)$ as the first element of the basis for $G$ and pass to the quotient $G/\langle \phi_(h_1) \rangle$. Consider now the projection of $\phi(h_2), \ldots, \phi(h_m)$, and suppose $\phi(h_2)$ has maximal order in the quotient (thus again it is a direct summand in the quotient): then take $\phi(h_2)$ as second element element of the basis for $G$, and so on.
To my big surprise, I think this property need not be true when $G$ is not a $p$-group, although I am not sure I have a complete proof for this. My example is in the case $G=\mathbb{Z}_2 \oplus \mathbb{Z}_8$ $\oplus \mathbb{Z}_3 \oplus \mathbb{Z}27$ with the elements $\phi(h_1)= (1,2,0,1)$ and $\phi(h_2)=(0,1,1,3)$.
