Index: trunk/ippTools/share/chiptool_pendingcleanuprun.sql
===================================================================
--- trunk/ippTools/share/chiptool_pendingcleanuprun.sql	(revision 36384)
+++ trunk/ippTools/share/chiptool_pendingcleanuprun.sql	(revision 36431)
@@ -4,8 +4,11 @@
     rawExp.exp_tag,
     chipRun.state,
-    chipRun.workdir
+    chipRun.workdir,
+    chipRun.label,
+    IFNULL(Label.priority, 10000) AS priority
 FROM chipRun
 JOIN rawExp 
 USING (exp_id)
+LEFT JOIN Label ON chipRun.label = Label.label
 WHERE
     (chipRun.state = 'goto_cleaned' OR chipRun.state = 'goto_scrubbed' OR chipRun.state = 'goto_purged')
Index: trunk/ippTools/src/chiptool.c
===================================================================
--- trunk/ippTools/src/chiptool.c	(revision 36384)
+++ trunk/ippTools/src/chiptool.c	(revision 36431)
@@ -1255,5 +1255,5 @@
 
     psMetadata *where = psMetadataAlloc();
-    pxAddLabelSearchArgs (config, where, "-label", "label", "==");
+    pxAddLabelSearchArgs (config, where, "-label", "chipRun.label", "==");
 
     psString query = pxDataGet("chiptool_pendingcleanuprun.sql");
@@ -1269,4 +1269,6 @@
     }
     psFree(where);
+
+    psStringAppend(&query, "\nORDER BY priority DESC, chip_id");
 
     // treat limit == 0 as "no limit"
