} else if (PL_strlen(mapElementPtr->item2) < PL_strlen(mapElement->item2)) {
} else if (mapElementPtr->item2.Length() < item2.Length()) {
wallet_WriteToList(    const char* item1,    const char* item2,    nsVoidArray* itemList,    nsVoidArray*& list,    PRBool obscure,    PlacementType placement = DUP_BEFORE) {  wallet_MapElement * mapElementPtr;  PRBool added_to_list = PR_FALSE;  wallet_MapElement * mapElement = nsnull;  if (list == wallet_FieldToSchema_list || list == wallet_SchemaStrings_list ||      list == wallet_PositionalSchema_list || list == wallet_StateSchema_list ||      list == wallet_SchemaConcat_list  || list == wallet_DistinguishedSchema_list ||      list == wallet_VcardToSchema_list) {    wallet_AllocateMapElement(mapElement);  } else {    mapElement = new wallet_MapElement;  }  if (!mapElement) {    return PR_FALSE;  }  nsCAutoString item1UTF8(item1); ToLowerCase(item1UTF8);  mapElement->item1 = ToNewCString(item1UTF8);  mapElement->item2 = PL_strdup(item2);  mapElement->itemList = itemList;  if (obscure) {    char * crypt = nsnull;    if (NS_FAILED(EncryptString(mapElement->item2, crypt))) {      delete mapElement;      return PR_FALSE;    }    WALLET_FREEIF(mapElement->item2);    mapElement->item2 = crypt;  }  /* make sure the list exists */  if(!list) {    list = new nsVoidArray();    if(!list) {      delete mapElement;      return PR_FALSE;    }  }  /*   * Add new entry to the list in alphabetical order by item1.   * If identical value of item1 exists, use "placement" parameter to    * determine what to do   */  if (AT_END==placement) {    list->AppendElement(mapElement);    return PR_TRUE;  }  PRInt32 count = LIST_COUNT(list);  for (PRInt32 i=0; i<count; i++) {    mapElementPtr = NS_STATIC_CAST(wallet_MapElement*, list->ElementAt(i));    if (BY_LENGTH==placement) {      if (LIST_COUNT(mapElementPtr->itemList) < LIST_COUNT(itemList)) {        list->InsertElementAt(mapElement, i);        added_to_list = PR_TRUE;        break;      } else if (LIST_COUNT(mapElementPtr->itemList) == LIST_COUNT(itemList)) {        if (itemList) {          wallet_Sublist * sublistPtr;          wallet_Sublist * sublistPtr2;          sublistPtr = NS_STATIC_CAST(wallet_Sublist*, mapElementPtr->itemList->ElementAt(0));          sublistPtr2 = NS_STATIC_CAST(wallet_Sublist*, itemList->ElementAt(0));          if(PL_strlen(sublistPtr->item) < PL_strlen(sublistPtr2->item)) {            list->InsertElementAt(mapElement, i);            added_to_list = PR_TRUE;            break;          }        } else if (PL_strlen(mapElementPtr->item2) < PL_strlen(mapElement->item2)) {          list->InsertElementAt(mapElement, i);          added_to_list = PR_TRUE;          break;        }      }    } else if(!PL_strcmp(mapElementPtr->item1, mapElement->item1)) {      if (DUP_OVERWRITE==placement) {        delete mapElement;        mapElementPtr->item1 = mapElement->item1;        mapElementPtr->item2 = mapElement->item2;        mapElementPtr->itemList = itemList;      } else if (DUP_BEFORE==placement) {        list->InsertElementAt(mapElement, i);      }      if (DUP_AFTER!=placement) {        added_to_list = PR_TRUE;        break;      }    } else if(PL_strcmp(mapElementPtr->item1, mapElement->item1)>=0) {      list->InsertElementAt(mapElement, i);      added_to_list = PR_TRUE;      break;    }  }  if (!added_to_list) {    list->AppendElement(mapElement);  }  return PR_TRUE;}