I have a table stored in continuous memory. It should remain in this format after sorting.
For instance:
int table[5][3] = {
{ 60, 5, 10 },
{ 0, 200, 15 },
{ 55, 50, 365 },
{ 4, 7, 78 },
{ 555, 8, 11 },
};
Except for much larger (the largest in bytes is about 27 KB). Each cell is always int32, and all rows have the same number of columns.
Let's say that I want to sort it based on the first column, so the result should be equivalent:
{ 0, 200, 15 },
{ 4, 7, 78 },
{ 55, 50, 365 },
{ 60, 5, 10 },
{ 555, 8, 11 },
What is the best way to do this? I think there is a better way than converting this to std::list, call sort()and convert back.
Also, something built into C ++ where I just need to call some function would be better.