Sorting with c++ algorithm
<p>I want to sort chopsticks by weight and I want the matching pair of chopstick at the end of program. Should I use sort algorithm? I want to sort it by weight means (e.g 110, 90, 110, 90) so in this case I got 2 pair. One having weight 90 and other having weight 110, but how can I track that? I know I have to use counter but how I don not know. </p>

<pre><code>#include&lt;iostream&gt;
#include&lt;algorithm&gt;
#include&lt;vector&gt; 

using namespace std; 

bool myChopsticks (int i, int j) 
{
return (i&lt;j);
} 

int main() 
{ 
int myintergers []= {90, 110, 90, 110}; 

vecotr&lt;int&gt; myvector(myintergers, myintergers+4); 

vector&lt;int&gt;::iterator it; 
sort (myvector.begin(), myvector.end()+2);
 cout &lt;&lt; "myvector contains:"; 

for (it=myvector.begin(); it!=myvector.end(); ++it) 

cout &lt;&lt; " " &lt;&lt; *it; cout &lt;&lt; endl;
 return 0;
}
</code></pre>
