title: c++ custom comprator for more than attribute
body: <p>I am trying to implement a naive File System.
  I have this class</p>
  
  <pre><code>class BaseFile {
  private:
      string name;
  
  public:
      BaseFile(string name);
      string getName() const;
      void setName(string newName);
          bool operator &lt; (const BaseFile&amp; str) const;
          bool operator &gt; (const BaseFile&amp; str) const;
  
      virtual int getSize() = 0;
  
  };
  </code></pre>
  
  <p>and the subclass </p>
  
  <pre><code>class Directory : public BaseFile {
  private:
      vector&lt;BaseFile*&gt; children;
      Directory *parent;
  
  public:
      Directory(string name, Directory *parent); r
      Directory *getParent() const; 
      void setParent(Directory *newParent); 
      void removeFile(string name); 
      void removeFile(BaseFile* file); 
      void sortByName(); 
      bool SortSize(BaseFile&amp; a , BaseFile&amp; b);
      void sortBySize(); 
      vector&lt;BaseFile*&gt; getChildren(); n
      int getSize(); 
      string getAbsolutePath();  
  
  };
  </code></pre>
  
  <p>I need to sort the <code>vector&lt;BaseFile*&gt;</code> children once by the attribute size by activating the function <code>SortBySize()</code>.
  And by name by the function <code>SortByName()</code>.
  I cant use sort algorithm I want to use <code>std::sort()</code></p>
  
  <p>For the names I overloaded the operators <code>&lt;</code> <code>&gt;</code> and for the numbers(size) I want to define a custom comparison function.</p>
  
  <p>I defined the function in the class <code>Directory</code>. I tried to make is static it didn't work</p>
  
  <pre><code>bool Directory::SortSize(BaseFile&amp; a , BaseFile&amp; b) 
  {
      return (a.getSize() &lt; b.getSize());
  }
  </code></pre>
  
  <p>but when I use <code>std::(children.begin(), children.end(), sortSize)</code></p>
  
  <p>I get "invalid use of non-static member function".
  Any help?</p>