History

Issue 122: Allow floating point return values from Array.sort callback.

Tor Andersson committed 6 years ago

Commit e690d311 parent b4484ab1 file · +3 −1Browse files

Showing the changes to jsarray.c (1 of 1 file). Show all

Unified · Split

jsarray.c+3−1
@@ -259,6 +259,7 @@ static int sortcmp(const void *avoid, const void *bvoid) · 258 unmodified lines
259 const js_Value *a = &aslot->v, *b = &bslot->v;259 const js_Value *a = &aslot->v, *b = &bslot->v;
260 js_State *J = aslot->J;260 js_State *J = aslot->J;
261 const char *sx, *sy;261 const char *sx, *sy;
262 double v;
262 int c;263 int c;
263 264
264 int unx = (a->type == JS_TUNDEFINED);265 int unx = (a->type == JS_TUNDEFINED);
@@ -272,7 +273,8 @@ static int sortcmp(const void *avoid, const void *bvoid) · 7 unmodified lines
272 js_pushvalue(J, *a);273 js_pushvalue(J, *a);
273 js_pushvalue(J, *b);274 js_pushvalue(J, *b);
274 js_call(J, 2);275 js_call(J, 2);
275 c = js_tonumber(J, -1);276 v = js_tonumber(J, -1);
277 c = (v == 0) ? 0 : (v < 0) ? -1 : 1;
276 js_pop(J, 1);278 js_pop(J, 1);
277 } else {279 } else {
278 js_pushvalue(J, *a);280 js_pushvalue(J, *a);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t