lib/db: calc_rrdep_counts: count packages waiting for a package

Signed-off-by: Andreas Beckmann <anbe@debian.org>
lib/db: sort packages returned by reserve() by importance

use descending waiting_count() as primary sort key
(ideally we should use waiting_depth() as first sort key, but that
attribute is not computed and waiting_count should be a useful
approximation)
and shuffle packages with the same waiting_count

this should move packages from waiting-for-dependency-to-be-tested
to waiting-to-be-tested state earlier

Signed-off-by: Andreas Beckmann <anbe@debian.org>