I tried to use lambda function with sort, but was getting \"Segmentation fault\" errors. I managed to simplify the code to the following:
#inclu
The predicate is supposed to implement a simple, weak ordering. Also your range is off if you want to sort the entire thing. (I missed that that was intentional.) So all in all we're looking for something like this:
std::sort(intArr, intArr + nelems, [](int a, int b){ return a < b; });
Or even:
std::sort(intArr, intArr + nelems);
The default predicate for sorting is std::less, which does exactly what the lambda does.