** Return true iff value at stack index 'a' is less than the value at ** index 'b' (according to the order of the sort). */
| 289 | ** index 'b' (according to the order of the sort). |
| 290 | */ |
| 291 | static int sort_comp (lua_State *L, int a, int b) { |
| 292 | if (lua_isnil(L, 2)) /* no function? */ |
| 293 | return lua_compare(L, a, b, LUA_OPLT); /* a < b */ |
| 294 | else { /* function */ |
| 295 | int res; |
| 296 | lua_pushvalue(L, 2); /* push function */ |
| 297 | lua_pushvalue(L, a-1); /* -1 to compensate function */ |
| 298 | lua_pushvalue(L, b-2); /* -2 to compensate function and 'a' */ |
| 299 | lua_call(L, 2, 1); /* call function */ |
| 300 | res = lua_toboolean(L, -1); /* get result */ |
| 301 | lua_pop(L, 1); /* pop result */ |
| 302 | return res; |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | |
| 307 | /* |
no test coverage detected