【发布时间】:2011-10-30 04:14:22
【问题描述】:
我很难弄清楚,如何对字符串向量的向量进行排序,这里是测试代码。
#include <iostream>
#include <vector>
#include <boost/algorithm/string.hpp>
int main(int argc, char** argv) {
std::vector <std::vector <std::string> > data_var;
std::vector <std::string> temp;
std::string str1 = "1,hello3,temp2";
std::string str2 = "2,hello2,temp1";
std::string str3 = "3,hello1,temp3";
boost::split(temp, str1, boost::is_any_of(","));
data_var.push_back(temp);
boost::split(temp, str2, boost::is_any_of(","));
data_var.push_back(temp);
boost::split(temp, str3, boost::is_any_of(","));
data_var.push_back(temp);
// sorting code here...
}
提前谢谢...
【问题讨论】:
-
那么...您注释掉的排序代码是否损坏?还是您只是想让我们为您实现排序代码?
-
你怎么知道
vector<string>应该在另一个之前还是之后? -
@SB:我不知道如何排序...
-
a 向量
> 可以被认为是字符串的二维数组,或字符的 3d 数组。您希望如何排序? -
@Bill:改变了字符串...