On 2011/03/14 23:23:01, Jungshik Shin wrote:
Thank you for the explanation.
Is there any way to make 'array.sort(coll.compare)' work on my side (in
C++)
or
is that the way sort() is supposed to work no matter what? It seems that
the
latter is the case, but I'd better ask you to make sure.
This is just the way JavaScript works. You are extracting the function and
calling it with a receiver that is not a collator. You are right that you
cannot
make this work this way. I don't think you should in any case because this
is
not how JS works.
I guess many callers want to define their own compare function any way
because
they're likely to compare more complex objects than simple strings. For
instance, a file browser may want to list directories before regular
files and
would use the following:
var compareFileName = function(a, b) {
if (a.type == b.type) { return coll.compare(a.name, b.name);}
if (a.type =="directory") return -1;
return 1;
}
So, not being able to directly pass coll.compare() is probably ok.
However, if
there's any way to make it possible, pls let me know.
http://codereview.chromium.org/6673011/
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev