  The main objective of this work is to bring together two well known and, a
priori, unrelated theories dealing with weighted inequalities for the
Hardy-Littlewood maximal operator $M$, and thus, we consider the boundedness of
$M$ in the weighted Lorentz space $\Lambda^p_u(w)$. Two examples are
historically relevant as a motivation: If $w=1$, this corresponds to the study
of the boundedness $M:L^p(u)\longrightarrow L^p(u),$ which was characterized by
B. Muckenhoupt, giving rise to the so called $A_p$ weights. The second case is
when we take $u=1$. This is a more recent theory, and was completely solved by
M.A. Ari\~no and B. Muckenhoupt in 1991. It turns out that the boundedness
$M:\llo\longrightarrow\llo,$ can be seen to be equivalent to the boundedness of
the Hardy operator $A$ restricted to decreasing functions of $L^p(w)$. The
class of weights satisfying this boundedness is known as $B_p$. Even though the
$A_p$ and $B_p$ classes enjoy some similar features, they come from very
different theories, and so are the techniques used on each case:
Calder\'on--Zygmund decompositions and covering lemmas for $A_p$, rearrangement
invariant properties and positive integral operators for $B_p$. It is our aim
to give a unified version of these two theories. Contrary to what one could
expect, the solution is not given in terms of the limiting cases above
considered (i.e., $u=1$ and $w=1$), but in a rather more complicated condition,
which reflects the difficulty of estimating the distribution function of the
Hardy-Littlewood maximal operator with respect to general measures.
