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 152799 1a68749afae0cb04694c8e66b676873d1c465d24
parent 152798 044418e079879fe84b4eddd77966f3e800a22edb
child 152800 d47539d6c15fa0d06d4d2ce3995259bcacffaf38
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [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);