+
+/*
+ * Compare according to load average.
+ */
+lcmp(h1, h2)
+ struct hs *h1, *h2;
+{
+
+ if (down(h1))
+ if (down(h2))
+ return (tcmp(h1, h2));
+ else
+ return (1);
+ else if (down(h2))
+ return (-1);
+ else
+ return (h2->hs_wd->wd_loadav[0] - h1->hs_wd->wd_loadav[0]);
+}
+
+/*
+ * Compare according to number of users.
+ */
+ucmp(h1, h2)
+ struct hs *h1, *h2;
+{
+
+ if (down(h1))
+ if (down(h2))
+ return (tcmp(h1, h2));
+ else
+ return (1);
+ else if (down(h2))
+ return (-1);
+ else
+ return (h2->hs_nusers - h1->hs_nusers);
+}
+
+/*
+ * Compare according to uptime.
+ */
+tcmp(h1, h2)
+ struct hs *h1, *h2;
+{
+ long t1, t2;
+
+ return (
+ (down(h2) ? h2->hs_wd->wd_recvtime - now
+ : h2->hs_wd->wd_sendtime - h2->hs_wd->wd_boottime)
+ -
+ (down(h1) ? h1->hs_wd->wd_recvtime - now
+ : h1->hs_wd->wd_sendtime - h1->hs_wd->wd_boottime)
+ );
+}