Latex: When Algorithms and Hyperref hate each other

When using algorithms in Latex and trying to use hyperref to produce automatic links in the references that one uses in LaTeX documents one usually finds out that although the references are printed correctly, the links for algorithms don’t work (usually pointing to the first page in the document). If you investigate the messages of the output you usually find:

pdfTeX warning (dest): name{algorithm.1} has been referenced
but does not exist, replaced by a fixed one

Well, the problem is that for some reason hyperref doesn’t work correctly with the algorithm and float packages. The trick to solve this is to push the use of hyperref package down the most in the preamble (without breaking anything) and then put the float package before hyperref and algorithm package after hyperref like in the example below:

...
\usepackage{float} % Before hyperref
\usepackage{hyperref} 
\usepackage{algorithm} % After hyperref
\begin{document}
...

This seems to solve the problem, and there are other situations where one might want to be careful with the order we load packages.

Does this solve the problem for you?