For positive discriminants d, let h(d) and R(d) be class number and regulator of the real quadratic field Q(sqrt(d)). In 1944 Siegel computed the asymptotic for the sum of h(d)R(d), where one orders the summands by increasing discriminants d. If we change ordering and we list h(d) according to the size of the regulators R(d), it is possible to prove a different asymptotic, and to (partially) separate the information attached to h(d) and to R(d). In the talk I will explain how this problem is related to the prime geodesic theorem and to the spectral theory of automorphic forms, which provides useful techniques to prove an asymptotic with strong bounds on the error term. I will also quickly explain how the methods generalize to study certain class numbers of quadratic forms over Gaussian integers.