Bug 851440 - Sort same contacts by published-order. r=gwagner
authorKay Lee <km.lee009@gmail.com>
Tue, 30 Jul 2013 09:44:16 -0400
changeset 140521 1a68749afae0cb04694c8e66b676873d1c465d24
parent 140520 044418e079879fe84b4eddd77966f3e800a22edb
child 140522 d47539d6c15fa0d06d4d2ce3995259bcacffaf38
push id25032
push userryanvm@gmail.com
push dateTue, 30 Jul 2013 22:07:36 +0000
treeherdermozilla-central@60bf7ceba890 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgwagner
bugs851440
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 851440 - Sort same contacts by published-order. r=gwagner
dom/contacts/fallback/ContactDB.jsm
--- a/dom/contacts/fallback/ContactDB.jsm
+++ b/dom/contacts/fallback/ContactDB.jsm
@@ -900,26 +900,35 @@ ContactDB.prototype = {
         do {
           while (xIndex < sortBy.length && !x) {
             x = a.properties[sortBy[xIndex]];
             if (x) {
               x = x.join("").toLowerCase();
             }
             xIndex++;
           }
-          if (!x) {
-            return sortOrder == "descending" ? 1 : -1;
-          }
           while (yIndex < sortBy.length && !y) {
             y = b.properties[sortBy[yIndex]];
             if (y) {
               y = y.join("").toLowerCase();
             }
             yIndex++;
           }
+          if (!x) {
+            if (!y) {
+              let px, py;
+              px = JSON.stringify(a.published);
+              py = JSON.stringify(b.published);
+              if (px && py) {
+                return px.localeCompare(py);
+              }
+            } else {
+              return sortOrder == 'descending' ? 1 : -1;
+            }
+          }
           if (!y) {
             return sortOrder == "ascending" ? 1 : -1;
           }
 
           result = x.localeCompare(y);
           x = null;
           y = null;
         } while (result == 0);