} if (NS_FAILED(rv)) { sortOrder = nsCRT::strcasecmp(uni1, uni2);
XULSortServiceImpl::CompareNodes(nsIRDFNode *cellNode1, PRBool isCollationKey1,				 nsIRDFNode *cellNode2, PRBool isCollationKey2,				 PRBool &bothValid, PRInt32 & sortOrder){	bothValid = PR_FALSE;	sortOrder = 0;	const PRUnichar			*uni1 = nsnull, *uni2 = nsnull;	nsCOMPtr<nsIRDFLiteral>		literal1 = do_QueryInterface(cellNode1);	nsCOMPtr<nsIRDFLiteral>		literal2 = do_QueryInterface(cellNode2);	if (literal1)	literal1->GetValueConst(&uni1);	if (literal2)	literal2->GetValueConst(&uni2);	if (isCollationKey1 == PR_TRUE && isCollationKey2 == PR_TRUE)	{		bothValid = PR_TRUE;		// sort collation keys		if (collationService)		{            collationService->CompareRawSortKey((const PRUint8 *) uni1,                nsCRT::strlen(uni1) * sizeof(PRUnichar),                (const PRUint8 *) uni2,                nsCRT::strlen(uni2) * sizeof(PRUnichar),                &sortOrder);					}		else		{			// without a collation service, unable to collate			sortOrder = 0;		}	}	else if ((isCollationKey1 == PR_TRUE) && (isCollationKey2 == PR_FALSE))	{		sortOrder = -1;	}	else if ((isCollationKey1 == PR_FALSE) && (isCollationKey2 == PR_TRUE))	{		sortOrder = 1;	}	else if (literal1 || literal2)	{		// not a collation key, but one or both are strings		if (literal1 && literal2)		{			if ((*uni1) && (*uni2))			{				bothValid = PR_TRUE;				sortOrder = 0;  				if(collationService) 				{					nsAutoString v1(uni1);					nsAutoString v2(uni2);					collationService->CompareString(						kCollationCaseInSensitive,						v1,v2,&sortOrder);				}			}			else if (*uni1)	sortOrder = -1;			else		sortOrder = 1;		}		else if (literal1)	sortOrder = -1;		else			sortOrder = 1;	}	else	{		// not a collation key, and both aren't strings, so try other data types (ints)		nsCOMPtr<nsIRDFInt>		intLiteral1 = do_QueryInterface(cellNode1);		nsCOMPtr<nsIRDFInt>		intLiteral2 = do_QueryInterface(cellNode2);		if (intLiteral1 || intLiteral2)		{    		if (intLiteral1 && intLiteral2)    		{    			PRInt32			intVal1, intVal2;    			intLiteral1->GetValue(&intVal1);    			intLiteral2->GetValue(&intVal2);    			bothValid = PR_TRUE;    			sortOrder = 0;    			if (intVal1 < intVal2)		sortOrder = -1;    			else if (intVal1 > intVal2)	sortOrder = 1;    		}    		else if (intLiteral1)	sortOrder = -1;    		else					sortOrder = 1;		}		else		{			sortOrder = 0;			// not a collation key, and both aren't strings/ints, so try dates			nsCOMPtr<nsIRDFDate>		dateLiteral1 = do_QueryInterface(cellNode1);			nsCOMPtr<nsIRDFDate>		dateLiteral2 = do_QueryInterface(cellNode2);			if (dateLiteral1 && dateLiteral2)			{				PRInt64			dateVal1, dateVal2;				dateLiteral1->GetValue(&dateVal1);				dateLiteral2->GetValue(&dateVal2);				bothValid = PR_TRUE;				if (LL_CMP(dateVal1, <, dateVal2))	sortOrder = -1;				else if (LL_CMP(dateVal1, >, dateVal2))	sortOrder = 1;			}			else if (dateLiteral1)	sortOrder = -1;			else if (dateLiteral2)	sortOrder = 1;		}	}	return(NS_OK);}