C++ Class & .H Sorting
<p>Good evening experts and gurus !!</p>

<p>I have an array object that record the following..</p>

<p>This is at <strong>record.h</strong> </p>

<pre><code>Class Record
{
private:
string name;
int data;
float valueData;
public:
bool operator&lt;(const Record&amp;) const;
}
</code></pre>

<p>and the constructor are created at <strong>record.cpp</strong></p>

<p>record.cpp i added this</p>

<pre><code>bool Record::operator&lt;(const Record&amp; rhs) const
{
return valueData &lt; rhs.valueData;
}
</code></pre>

<p>At main.cpp I created record Array of Size 10</p>

<pre><code>#include "record.h"

Record rec[10];
</code></pre>

<p>I did</p>

<pre><code>sort(&amp;rec[0], &amp;rec[2]);
</code></pre>

<p><strong>but nothing seems changing or sorted</strong>.. i got 3 element , rec[0], rec[1], rec[2] and i want sort them ,but they are of another header file record.h &amp; its record.cpp which describe above.</p>

<p><strong>Original Question</strong>
Next is  i recorded several value to the object </p>

<p>and now rec got 3 index</p>

<pre><code>rec[0]
name = "jack1"
data = 1
valueData = 20

rec[1]
name = "jack2"
data = 2
valueData = 15

rec[2]
name = "jack3"
data = 3
valueData = 25
</code></pre>

<p>What i want to achieve is do a sort that can rearrange this array by <strong>valueData</strong> highest ascending form so.. it will be</p>

<p><code>rec[2]</code> then <code>rec[0]</code> then <code>rec[1]</code> ..</p>

<p>but i wanna sort by class array object. and re-arrange the value together , how do i achieve this.</p>

<p>the 3 value is private, so i not sure where do i create the sort function, at main.cpp or at record.cpp , next is how do i sort it so it can output in the way below..</p>

<pre><code>-- Highest to lowest --
1) Name: Jack3, Data = 3, Value =25
2) Name: Jack1 , Data =1 , Value = 20
3) Name: Jack2, Data = 2, Value = 15
</code></pre>

<p><strong>Thanks for all help and guide!!</strong></p>
