| 176 | } |
| 177 | |
| 178 | static int sort_comp (lua_State *L, int a, int b) { |
| 179 | if (!lua_isnil(L, 2)) { /* function? */ |
| 180 | int res; |
| 181 | lua_pushvalue(L, 2); |
| 182 | lua_pushvalue(L, a-1); /* -1 to compensate function */ |
| 183 | lua_pushvalue(L, b-2); /* -2 to compensate function and `a' */ |
| 184 | lua_call(L, 2, 1); |
| 185 | res = lua_toboolean(L, -1); |
| 186 | lua_pop(L, 1); |
| 187 | return res; |
| 188 | } |
| 189 | else /* a < b? */ |
| 190 | return lua_lessthan(L, a, b); |
| 191 | } |
| 192 | |
| 193 | static void auxsort (lua_State *L, int l, int u) { |
| 194 | while (l < u) { /* for tail recursion */ |
no test coverage detected