result = nsCRT::strcasecmp(lstr, rstr);
result = ::Compare(nsDependentString(lstr), nsDependentString(rstr), nsCaseInsensitiveStringComparator());
nsXULOutlinerBuilder::CompareMatches(nsTemplateMatch* aLeft, nsTemplateMatch* aRight){    PRInt32 result = 0;    if (mSortDirection == eDirection_Natural) {        // If the sort order is ``natural'', then see if the container        // is an RDF sequence. If so, we'll try to use the ordinal        // properties to determine order.        //        // XXX the problem with this is, it doesn't always get the        // *real* container; e.g.,        //        //  <outlinerrow uri="?uri" />        //        //  <triple subject="?uri"        //          predicate="http://home.netscape.com/NC-rdf#subheadings"        //          object="?subheadings" />        //        //  <member container="?subheadings" child="?subheading" />        //        // In this case mContainerVar is bound to ?uri, not        // ?subheadings. (The ``container'' in the template sense !=        // container in the RDF sense.)        Value val;        aLeft->GetAssignmentFor(mConflictSet, mContainerVar, &val);        nsIRDFResource* container = VALUE_TO_IRDFRESOURCE(val);        PRBool isSequence = PR_FALSE;        gRDFContainerUtils->IsSeq(mDB, container, &isSequence);        if (! isSequence)            // If it's not an RDF container, then there's no natural            // order.            return 0;        // Determine the indices of the left and right elements in the        // container.        Value left;        aLeft->GetAssignmentFor(mConflictSet, mMemberVar, &left);        PRInt32 lindex;        gRDFContainerUtils->IndexOf(mDB, container, VALUE_TO_IRDFNODE(left), &lindex);        if (lindex < 0)            return 0;        Value right;        aRight->GetAssignmentFor(mConflictSet, mMemberVar, &right);        PRInt32 rindex;        gRDFContainerUtils->IndexOf(mDB, container, VALUE_TO_IRDFNODE(right), &rindex);        if (rindex < 0)            return 0;        return lindex - rindex;    }    // If we get here, then an ascending or descending sort order is    // imposed.    Value leftValue;    aLeft->GetAssignmentFor(mConflictSet, mSortVariable, &leftValue);    nsIRDFNode* leftNode = VALUE_TO_IRDFNODE(leftValue);    Value rightValue;    aRight->GetAssignmentFor(mConflictSet, mSortVariable, &rightValue);    nsIRDFNode* rightNode = VALUE_TO_IRDFNODE(rightValue);    {        // Literals?        nsCOMPtr<nsIRDFLiteral> l = do_QueryInterface(leftNode);        if (l) {            nsCOMPtr<nsIRDFLiteral> r = do_QueryInterface(rightNode);            if (r) {                const PRUnichar *lstr, *rstr;                l->GetValueConst(&lstr);                r->GetValueConst(&rstr);                if (mCollation) {                    mCollation->CompareRawSortKey(NS_REINTERPRET_CAST(const PRUint8*, lstr),                                                        nsCRT::strlen(lstr) * sizeof(PRUnichar),                                                        NS_REINTERPRET_CAST(const PRUint8*, rstr),                                                        nsCRT::strlen(rstr) * sizeof(PRUnichar),                                                        &result);                }                else                    result = nsCRT::strcasecmp(lstr, rstr);                return result * mSortDirection;            }        }    }    {        // Dates?        nsCOMPtr<nsIRDFDate> l = do_QueryInterface(leftNode);        if (l) {            nsCOMPtr<nsIRDFDate> r = do_QueryInterface(rightNode);            if (r) {                PRTime ldate, rdate;                l->GetValue(&ldate);                r->GetValue(&rdate);                PRInt64 delta;                LL_SUB(delta, ldate, rdate);                if (LL_IS_ZERO(delta))                    result = 0;                else if (LL_GE_ZERO(delta))                    result = 1;                else                    result = -1;                return result * mSortDirection;            }        }    }    {        // Integers?        nsCOMPtr<nsIRDFInt> l = do_QueryInterface(leftNode);        if (l) {            nsCOMPtr<nsIRDFInt> r = do_QueryInterface(rightNode);            if (r) {                PRInt32 lval, rval;                l->GetValue(&lval);                r->GetValue(&rval);                result = lval - rval;                return result * mSortDirection;            }        }    }    // Ack! Apples & oranges...    return 0;}