对二维数组进行快速排序的 方法

解决问题 的方法 千千万  在这里我就写一种自己认为比较好的   排序思想吧 . 

最初的时候 我想的是  这样的

#include<cstdio>
#include<algorithm>
using namespace std;
bool cmp(int a[],int b[])
{
    return a[0]>b[0];
}
int main()
{
    int a[3][2]={3,4,1,2,5,6};
    sort(a,a+3,cmp);
}

然而 编译的时候 是有 错误的   可能 sort 无法传送二维数组

然而 有困难就一定有 克服困难的方法  当引入结构体的时候就注定了 这个问题可以简单的解决掉 .

#include<cstdio>
#include<algorithm>
using namespace std;
struct tm
{
    int v[4];
};
bool cmp(tm a,tm b)
{
    return a.v[3]<b.v[3];
}
int main()
{
     tm m[1000];
     sort(m,m+1000,cmp);
}

这个  二位数组排序 我感觉还是在   对字符进行排序比较好一点 因为有    strcmp函数的存在

 1 #include<iostream>
 2 #include<algorithm>
 3 #include<string>
 4 using namespace std;
 5 int main()
 6 {
 7     string strin[3],temp;
 8     strin[0]="a  s",strin[1]="bs";strin[2]="az";
 9     strin[0]=strin[1]+strin[0];
10     //sort(strin,strin+3);                                // 神器  可以对二维数组 进行排序  而且 还可以 直接进行  赋值  和 加法 运算 . 666
11     strin[2]=strin[1];
12     cout<<strin[0]<<"********* "<<strin[2];
13 }
原文地址:https://www.cnblogs.com/A-FM/p/5215827.html