--- affiliates.module   2007-04-15 23:34:57.000000000 -0500
+++ affiliates.module.new       2007-04-24 22:37:52.000000000 -0500
@@ -510,10 +510,11 @@

   // Populate it with the users and total clicks
   db_query("INSERT INTO {affiliates_summary}
-    SELECT a.user_id, SUM(aa.points), 0
+    SELECT a.user_id, SUM(aa.points) as lp, 0
     FROM {affiliates} a, {affiliates_ads} aa
     WHERE aa.ad_id = a.ad_id
     GROUP BY a.user_id
+    ORDER BY lp DESC
     LIMIT %d", $limit);

   // Some SQL wizardry to update the period
