JS_ReportError(cx, "invalid Array.prototype.sort argument");
JS_ReportErrorNumber(cx, NULL, JSMSG_BAD_PROTO_SORT);
array_sort(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval){    jsval fval;    CompareArgs ca;    jsuint len, i;    jsval *vec;    jsid id;    if (argc > 0) {	if (JSVAL_IS_PRIMITIVE(argv[0])) {	    JS_ReportError(cx, "invalid Array.prototype.sort argument");	    return JS_FALSE;	}	fval = argv[0];    } else {	fval = JSVAL_NULL;    }    if (!js_GetLengthProperty(cx, obj, &len))    	return JS_FALSE;    vec = JS_malloc(cx, (size_t) len * sizeof(jsval));    if (!vec)	return JS_FALSE;    for (i = 0; i < len; i++) {	ca.status = IndexToId(cx, i, &id);	if (!ca.status)	    goto out;	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_qsort(vec, (size_t) len, sizeof(jsval), sort_compare, &ca)) {	JS_ReportOutOfMemory(cx);	ca.status = JS_FALSE;    }    if (ca.status) {	ca.status = InitArrayObject(cx, obj, len, vec);	if (ca.status)	    *rval = OBJECT_TO_JSVAL(obj);    }out:    if (vec)	JS_free(cx, vec);    return ca.status;}