Index: trunk/ippTools/src/warptool.c
===================================================================
--- trunk/ippTools/src/warptool.c	(revision 28056)
+++ trunk/ippTools/src/warptool.c	(revision 28082)
@@ -940,15 +940,12 @@
 
     // treat limit == 0 as "no limit"
-    psString limitString = psStringCopy("\n");
+    psString limitString = psStringCopy("\nORDER BY priority DESC, warp_id");
     if (limit) {
-        // We apply the limit to both sides of the UNION
-        // to avoid slow queries and to the query itself
-        // to satisfy the user's requested limit
+        // We apply the limit to both sides of the UNION to avoid slow queries
+        // and to the query itself to satisfy the user's requested limit
         psStringAppend(&limitString, "%s", psDBGenerateLimitSQL(limit));
         psStringAppend(&query, " %s", limitString);
     }
 
-#define TWO_WHERES
-#ifdef TWO_WHERES
     if (!p_psDBRunQueryF(config->dbh, query, whereStr, limitString, whereStr,  limitString)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
@@ -956,11 +953,4 @@
         return false;
     }
-#else
-    if (!p_psDBRunQueryF(config->dbh, query, whereStr)) {
-        psError(PS_ERR_UNKNOWN, false, "database error");
-        psFree(query);
-        return false;
-    }
-#endif
     psFree(limitString);
     psFree(whereStr);
