if (!js_HeapSort(vec, (size_t) len, sizeof(jsval), sort_compare, &ca)) {
if (!js_HeapSort(vec, (size_t) len, sizeof(jsval), all_strings ? sort_compare_strings : sort_compare, &ca)) {
array_sort(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval){    jsval fval;    CompareArgs ca;    jsuint len, newlen, i;    jsval *vec;    jsid id;    if (argc > 0) {	if (JSVAL_IS_PRIMITIVE(argv[0])) {	    JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,				 JSMSG_BAD_SORT_ARG);	    return JS_FALSE;	}	fval = argv[0];    } else {	fval = JSVAL_NULL;    }    if (!js_GetLengthProperty(cx, obj, &len))	return JS_FALSE;    if (len == 0)        return JS_TRUE;    vec = (jsval *) JS_malloc(cx, (size_t) len * sizeof(jsval));    if (!vec)	return JS_FALSE;#if JS_HAS_SPARSE_ARRAYS    newlen = 0;#else    newlen = len;#endif    for (i = 0; i < len; i++) {	ca.status = IndexToId(cx, i, &id);	if (!ca.status)	    goto out;#if JS_HAS_SPARSE_ARRAYS        {            JSObject *obj2;            JSProperty *prop;            ca.status = OBJ_LOOKUP_PROPERTY(cx, obj, id, &obj2, &prop);            if (!ca.status)                goto out;            if (!prop) {                vec[i] = JSVAL_VOID;                continue;            }            OBJ_DROP_PROPERTY(cx, obj2, prop);            newlen++;        }#endif	ca.status = OBJ_GET_PROPERTY(cx, obj, id, &vec[i]);	if (!ca.status)	    goto out;    }    ca.context = cx;    ca.fval = fval;    ca.status = JS_TRUE;    if (!js_HeapSort(vec, (size_t) len, sizeof(jsval), sort_compare, &ca)) {	JS_ReportOutOfMemory(cx);	ca.status = JS_FALSE;    }    if (ca.status) {	ca.status = InitArrayElements(cx, obj, newlen, vec);	if (ca.status)	    *rval = OBJECT_TO_JSVAL(obj);#if JS_HAS_SPARSE_ARRAYS        /* set length of newly-created array object to old length. */        if (ca.status && newlen < len) {            ca.status = js_SetLengthProperty(cx, obj, len);            /* Delete any leftover properties greater than newlen. */            while (ca.status && newlen < len) {                jsval junk;                ca.status = !IndexToId(cx, newlen, &id) ||                    !OBJ_DELETE_PROPERTY(cx, obj, id, &junk);                newlen++;            }        }#endif    }out:    if (vec)	JS_free(cx, vec);    return ca.status;}