Order of pole and evaluating residue $f(z)=\frac{ze^{iz}}{z^2+a^2}$
I need to determine the order of the poles and compute the residues.
To compute this, we were told to (in general), write $f(z)=\frac{g(z)}{(z-z_0)^m}$ , and choose $g$ so that $m$ is minimized (a natural number -- this is the order of the pole), my issue is two fold:
1)How do we know, in general, that we have picked a $g$ which minimizes the order.
2) How do I handle this particular function (and others with essential singuarities).
I know I may also write $f(z) =\frac{ze^{iz}}{(z+ia)(z-ia)}$, so I know the singularities are $\frac{+}{ }ia$ and an 'essential singularitiy' (at infinity).  But not sure how to compute the residues....
EDIT:
$\lim_{z\to ∞} \frac{ze^{iz}}{z^2+a^2}=\lim_{z\to ∞} \frac{ze^{iz}}{z^2}=
\lim_{z\to ∞} \frac{e^{iz}}{z}=∞$
So I can't use the result for when the limit exists and is finite (zero or non-zero).  

I think that in general one has to be able to factor the function enough as to see the picture around some pole. In this particular case, as we have a rational function times an entire one, we can do:
$$z^2+a^2=(z-ai)(z+ai)$$
and from here we have two (or three, if you want to subdivide (2)) cases:
$$(1)\;\;\;a=0\Longrightarrow f(z)=\frac{ze^{iz}}{z^2}=\frac{e^{iz}}{z}\Longrightarrow \operatorname{Res}_{z=0}(f)=\lim_{z\to 0}z\,f(z)=\lim_{z\to 0}e^{iz}=e^0=1$$
$$(2)\;\;\;a\neq 0\Longrightarrow \operatorname{Res}_{z=\pm ai}(f)=\lim_{z\to\pm ai}(z\mp ai)\,f(z)=\lim_{z\to \pm ai}\frac{ze^{iz}}{z\mp ai}=\frac{\pm aie^{\mp a}}{\pm 2ai}=\frac{e^{\mp a}}{2}$$
