| erickulcyk (3) | |||
|
Hello, Currently I am sorting a dimensional array using the following cose:
I tried to use std::sort, but it complains that boxes is not of type int**. Is there a way to do this with std::sort? Thanks, Eric | |||
|
|
|||
| Cubbi (1572) | |||
|
std::sort requires that the value type of the iterator it's passed is assignable ( see http://en.cppreference.com/w/cpp/algorithm/sort for example). If you're planning to replace the call to qsort() with something like sort(boxes, boxes+k), you're passing pointers to 1D arrays of 10 int each, and raw C-style arrays are not assignable. To make them assignable, you can wrap them in structs (or some other suitable class types), which would make you reinvent std::array:
you could use vectors, too. | |||
|
|
|||