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