Bug 753414 - Contacts API: Add localized sorting. r=kaze
authorGregor Wagner <gwagner@mozilla.com>
Thu, 10 May 2012 09:41:49 -0700
changeset 93735 8cd71b91b4c6bbb0b8a583bf455d13a27bc5b6f8
parent 93734 1df2b3ab08cf42188b739c0976068c9ba9ffece9
child 93736 af2b5a6acb96629bd80d8c8cd036873dd5b21f1c
push id22667
push userjdrew@mozilla.com
push dateFri, 11 May 2012 01:26:16 +0000
treeherdermozilla-central@e6a9572b48f7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskaze
bugs753414
milestone15.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 753414 - Contacts API: Add localized sorting. r=kaze
dom/contacts/fallback/ContactService.jsm
--- a/dom/contacts/fallback/ContactService.jsm
+++ b/dom/contacts/fallback/ContactService.jsm
@@ -67,19 +67,18 @@ let DOMContactManager = {
 
   receiveMessage: function(aMessage) {
     function sortfunction(a, b){
       let x, y;
       if (a.properties[msg.findOptions.sortBy])
         x = a.properties[msg.findOptions.sortBy][0].toLowerCase();
       if (b.properties[msg.findOptions.sortBy])
         y = b.properties[msg.findOptions.sortBy][0].toLowerCase();
-      if (msg.findOptions == 'ascending')
-        return ((x < y) ? -1 : ((x > y) ? 1 : 0));
-      return ((x < y) ? 1 : ((x > y) ? -1 : 0));
+      let result = x.localeCompare(y);
+        return msg.findOptions.sortOrder == 'ascending' ? result : -result;
     }
     debug("Fallback DOMContactManager::receiveMessage " + aMessage.name);
     let msg = aMessage.json;
     switch (aMessage.name) {
       case "Contacts:Find":
         let result = new Array();
         this._db.find(
           function(contacts) {