我想对用户给出的行或列的2d数组进行排序。我有的代码可以按升序排序,但不能降序排列。使用sort()而不是升序C++
void sortArray(int arr[12][12], int index, int row)
{
if (row == 0)
{
sort(arr[index] , arr[index] + 12);
}
else
{
int tempArr[12];
getColArr(arr, tempArr, index);
sort(tempArr, tempArr + 12);
for (int i = 0; i < 12; i++)
{
arr[i][0] = tempArr[i];
}
}
}
如何将其更改为降序?
见http://stackoverflow.com/questions/4008253/how-to-sort-c-array-in -asc和 - 递减模式 – Javia1492