c++的sort问题 求大神帮忙(详细问题在代码注释中)

#include
#include
#include
#include
#include
using namespace std;

class Stick
{
public:
int length, weight;
Stick()
{
length = 0;
weight = 0;
}
bool operator<(Stick& stick)
{
/*
测试数据为
1
5
3 1 1 3 1 4 3 1 4 2
当(3,1)和(3,1)比较时会说我的<重载无效
但是改为注释部分代码后就OK了?(两者只有等号的位置不同----我知道意思不同但是也不至于报错呀)
/
if (length>stick.length)return false;
else if (length <=stick.length) return true;
/

if (length>=stick.length)return false;
else if (length <stick.length) return true;
*/

}

};

int main()
{

ios::sync_with_stdio(false);
int t, n, cnt;
Stick temp;
vector<Stick>vec;


cin >> t;
while (t--)
{
    vec.clear();
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> temp.length >> temp.weight;
        vec.push_back(temp);
    }
    sort(vec.begin(),vec.end());
    for (int i = 0; i < n; i++)
        cout <<vec[i].length << " " <<vec[i].weight << endl;
}
system("pause");
return 0;

}

你的输入是什么,按照你注释的输入,根本就运行不了。

已经修改了,麻烦您再帮忙看看

具体实现的分支不一样,根本问题是你的<重载函数的调用有问题