Reikriam

sort reproducer

Jun 19th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <numeric>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6. int main() {
  7. std::vector<int64_t> result(10);
  8. std::iota(result.begin(), result.end(), 0);
  9. auto start = std::next(result.begin(), 1);
  10. auto stop = std::next(result.begin(), 4);
  11. const int64_t fromptr[10] = {100, 300, 200, 400, 500, 600, 700, 800, 1000, 900};
  12. std::stable_sort(start, stop, [&fromptr](int64_t i1, int64_t i2) {
  13. return fromptr[i1] < fromptr[i2];
  14. });
  15. //std::transform(start, stop, start, [&](int64_t j) -> int64_t {
  16. // return j - 3;
  17. //});
  18. for(int i=0; i < 10; i++)
  19. std::cout << result[i] << ' ';
  20. std::cout << "\n";
  21. return 0;
  22. }
Add Comment
Please, Sign In to add comment