Boost logo

Boost Users :

Subject: [Boost-users] boost::sort::spreadsort::integer_sort
From: v9v_at_[hidden]
Date: 2015-09-30 18:42:34


Hi!I'm a C++ beginner and any help would be very much appreciated.I would like to convert this "std::sort" into "boost::sort::spreadsort::integer_sort".I know that I have to write "#include <boost/sort/spreadsort/integer_sort.hpp>" inmy header instead of "#include <algorithm>" but after that, this is too difficult...Thanks!-------------------------------------------------------------------#include <iostream>#include <algorithm>using namespace std;int main() { int nb1[4] = {15, 5, 0, 20}; int nb2[4] = {99,102, 8, 2}; int indices[4]; for (short i=0; i<4; i++) indices[i]=i; sort(begin(indices), end(indices), [&](int i1, int i2) { return nb1[i1] < nb1[i2]; } ); for (short i=0; i<4; i++) cout << nb1[indices[i]] << ' '; cout <<endl; // 0 5 15 20 for (short i=0; i<4; i++) cout << nb2[indices[i]] << ' '; cout <<endl; // 8 102 99 2 return 0;}---------------------------------------------------------------------



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net