MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / sort_comp

Function sort_comp

Source/Misc/lua/src/lua.c:14724–14737  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14722}
14723
14724static int sort_comp (lua_State *L, int a, int b) {
14725if (!lua_isnil(L, 2)) { /* function? */
14726int res;
14727lua_pushvalue(L, 2);
14728lua_pushvalue(L, a-1); /* -1 to compensate function */
14729lua_pushvalue(L, b-2); /* -2 to compensate function and `a' */
14730lua_call(L, 2, 1);
14731res = lua_toboolean(L, -1);
14732lua_pop(L, 1);
14733return res;
14734}
14735else /* a < b? */
14736return lua_lessthan(L, a, b);
14737}
14738
14739static void auxsort (lua_State *L, int l, int u) {
14740while (l < u) { /* for tail recursion */

Callers 1

auxsortFunction · 0.85

Calls 4

lua_pushvalueFunction · 0.85
lua_callFunction · 0.85
lua_tobooleanFunction · 0.85
lua_lessthanFunction · 0.85

Tested by

no test coverage detected