我有一文本文件内容如下,
号码 金额(该行不包含在文件中)
87871234,25.5
87875472,585.5
87543532,12.25
....
共有纪录50万行左右,现在想把该文本文件按号码升序排序,不只如何实现,不只有什么好的算法,我用的是C++(vc)。高手请指点。
号码 金额(该行不包含在文件中)
87871234,25.5
87875472,585.5
87543532,12.25
....
共有纪录50万行左右,现在想把该文本文件按号码升序排序,不只如何实现,不只有什么好的算法,我用的是C++(vc)。高手请指点。
{
//compare
if(strcmp(r1->num,r2->num)>0)//sort principle
return true;
else
return false;
}struct record
{
char num[255];
double price;
};vector<record*> table;
//open file here
while(!eof(file))
{
record *r=new record();
cin>>r.num>>r.price;
table.push_back(r);
}sort(r.begin(),r.end(),myPre);//rewrite the file here
//close file here
#include<algorithm>using namespace std;