MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / sort_comp

Function sort_comp

3rd/lua-5.4.3/src/ltablib.c:274–287  ·  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

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

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