Commit 7784988a authored by Jean-Benoist Leger's avatar Jean-Benoist Leger
Browse files

sort also in merge_list

parent 4440226f
......@@ -19,13 +19,7 @@ void Couple::Initialize(std::string S, int I)
bool Couple::operator<(const Couple &Other)
{
long int myintname = atol(GetName().c_str());
long int othintname = atol(Other.GetName().c_str());
if(myintname<othintname)
return true;
if(myintname>othintname)
return false;
return GetName() < Other.GetName();
return namecomparator(GetName(), Other.GetName());
}
std::string Couple::GetName() const
......@@ -38,3 +32,13 @@ int Couple::GetIndex() const
return Index;
}
bool namecomparator(const std::string & first, const std::string & second)
{
long int first_intname = atol(first.c_str());
long int second_intname = atol(second.c_str());
if(first_intname < second_intname)
return true;
if(first_intname > second_intname)
return false;
return first < second;
}
......@@ -23,4 +23,6 @@ public:
void Initialize(std::string S, int I);
};
bool namecomparator(const std::string & first, const std::string & second);
#endif // COUPLE_H
......@@ -168,7 +168,7 @@ std::list<Triple> merge_list(Couple *ind_list_1, Couple *ind_list_2,
current_index_1 = ind_list_1[i].GetIndex();
current_index_2 = ind_list_2[j].GetIndex();
i++; j++;
} else if (current_element_1 < current_element_2) {
} else if (ind_list_1[i] < ind_list_2[j]) {
current_element = current_element_1;
current_index_1 = ind_list_1[i].GetIndex();
current_index_2 = -1;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment