| 500 | } |
| 501 | |
| 502 | void Game_Variables::SortRange(int first_id, int last_id, bool asc) { |
| 503 | PrepareRange(first_id, last_id, "Invalid write sort(var[{},{}])!"); |
| 504 | auto& vv = _variables; |
| 505 | int i = std::max(0, first_id - 1); |
| 506 | if (i < last_id) { |
| 507 | auto sorter = [&](auto&& fn) { |
| 508 | std::stable_sort(vv.begin() + i, vv.begin() + last_id, fn); |
| 509 | }; |
| 510 | if (asc) { |
| 511 | sorter(std::less<>()); |
| 512 | } else { |
| 513 | sorter(std::greater<>()); |
| 514 | } |
| 515 | } |
| 516 | } |
| 517 | |
| 518 | void Game_Variables::ShuffleRange(int first_id, int last_id) { |
| 519 | PrepareRange(first_id, last_id, "Invalid write shuffle(var[{},{}])!"); |
no test coverage detected