mirror of
https://github.com/ccxvii/mujs.git
synced 2026-02-05 17:29:43 +08:00
Issue 122: Allow floating point return values from Array.sort callback.
This commit is contained in:
@@ -259,6 +259,7 @@ static int sortcmp(const void *avoid, const void *bvoid)
|
||||
const js_Value *a = &aslot->v, *b = &bslot->v;
|
||||
js_State *J = aslot->J;
|
||||
const char *sx, *sy;
|
||||
double v;
|
||||
int c;
|
||||
|
||||
int unx = (a->type == JS_TUNDEFINED);
|
||||
@@ -272,7 +273,8 @@ static int sortcmp(const void *avoid, const void *bvoid)
|
||||
js_pushvalue(J, *a);
|
||||
js_pushvalue(J, *b);
|
||||
js_call(J, 2);
|
||||
c = js_tonumber(J, -1);
|
||||
v = js_tonumber(J, -1);
|
||||
c = (v == 0) ? 0 : (v < 0) ? -1 : 1;
|
||||
js_pop(J, 1);
|
||||
} else {
|
||||
js_pushvalue(J, *a);
|
||||
|
||||
Reference in New Issue
Block a user