sort by using a member of an object in c++
<p>I'd like to use sort() to do the following</p>

<ul>
<li>I have a text char[] T which is (private) member of a class. The text has length n. </li>
<li>I also ave an array int[] P that contains the first n integers. </li>
</ul>

<p>I'd like to std::sort P such that the lexicographic order among suffixes of T are preserved
i.e., for any <code>i &lt; j</code> we have that <code>T[P[i]...n]</code> is lex smaller than <code>T[P[j]...n]</code>.</p>

<p>I'm able to do it when <code>char[] T</code> is a global variable by defining </p>

<pre><code>bool myfunction (int i,int j) { 
  int m = i, l = j;
  while(m&lt;n and l &lt;n) {
      if(T[m] != T[l]) return (T[m]&lt;T[l]);
      m++; l++;
  }
  return (m&lt;l);
}
</code></pre>

<p>and calling <code>std::sort(P, P+n, myfuction)</code></p>

<p>I'm in truble when <code>T</code> is a member of an object (and sort is called by a method of that object). </p>

<p>How can I define <code>myfunction</code> so that <code>T</code> is visible? 
Should it be member of that object? If yes, how?
Thank you very much.</p>

<p>Edit: bool instead of int</p>
