MCPcopy Create free account
hub / github.com/DFHack/dfhack / sort_comp

Function sort_comp

depends/lua/src/ltablib.c:287–300  ·  view source on GitHub ↗

** Return true iff value at stack index 'a' is less than the value at ** index 'b' (according to the order of the sort). */

Source from the content-addressed store, hash-verified

285** index 'b' (according to the order of the sort).
286*/
287static int sort_comp (lua_State *L, int a, int b) {
288 if (lua_isnil(L, 2)) /* no function? */
289 return lua_compare(L, a, b, LUA_OPLT); /* a < b */
290 else { /* function */
291 int res;
292 lua_pushvalue(L, 2); /* push function */
293 lua_pushvalue(L, a-1); /* -1 to compensate function */
294 lua_pushvalue(L, b-2); /* -2 to compensate function and 'a' */
295 lua_call(L, 2, 1); /* call function */
296 res = lua_toboolean(L, -1); /* get result */
297 lua_pop(L, 1); /* pop result */
298 return res;
299 }
300}
301
302
303/*

Callers 2

partitionFunction · 0.85
auxsortFunction · 0.85

Calls 3

lua_compareFunction · 0.85
lua_pushvalueFunction · 0.85
lua_tobooleanFunction · 0.85

Tested by

no test coverage detected