MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / sort_comp

Function sort_comp

third-party/lua-5.5.0/src/ltablib.c:271–284  ·  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

269** index 'b' (according to the order of the sort).
270*/
271static int sort_comp (lua_State *L, int a, int b) {
272 if (lua_isnil(L, 2)) /* no function? */
273 return lua_compare(L, a, b, LUA_OPLT); /* a < b */
274 else { /* function */
275 int res;
276 lua_pushvalue(L, 2); /* push function */
277 lua_pushvalue(L, a-1); /* -1 to compensate function */
278 lua_pushvalue(L, b-2); /* -2 to compensate function and 'a' */
279 lua_call(L, 2, 1); /* call function */
280 res = lua_toboolean(L, -1); /* get result */
281 lua_pop(L, 1); /* pop result */
282 return res;
283 }
284}
285
286
287/*

Callers 2

partitionFunction · 0.70
auxsortFunction · 0.70

Calls 4

lua_compareFunction · 0.70
lua_pushvalueFunction · 0.70
lua_tobooleanFunction · 0.70
lua_callFunction · 0.50

Tested by

no test coverage detected