Hey, I'm using a database and im trying to sort a 2D array info that contains 51 pieces of records and 10 different fields for each record.
And, now I'm trying to sort a desired field in the 2D array alphabetically.
However, the other fields within the same record should be swapped together. (So that the information of the same records stays together).
Also, I am constantly experiencing a run-time error.
Sometimes my program works sometimes the whole thing crashes...
By opening the code in different folders sometimes works. But the problem is still here. Is there any way to fix this error?
//This is custom functor to use in std::sort, you can still sort manually
booloperator()(const RecordInfo& lhs, const RecordInfo& rhs)
return lhs.recordName < rhs.recordName;
//initialize your array here
std::sort(info, info+51, SortByName()); //Sorting
//Or use your sorting algorithm here.
//You will have to only swap structs encapsulating all data in one piece
//so you do not need to make sure that everything is swapped properly