title: why is the sort function of algorithm not working here and what will be the solution of this?
body: <pre><code>     struct Job{
            int id;
            int dead;
            int profit;
       };
  
      class Solution 
      {
          public:
            bool myfunc(Job i,Job j){
              return i.profit &gt; j.profit;
              }
      
        vector&lt;int&gt; JobScheduling(Job arr2[], int n) 
         { 
          vector&lt;int&gt; answer;
          Job arr[n];
          for(int i=0;i&lt;n;i++)arr[i]=arr2[i];
          int slot[INT_MAX];
          for(int i=0;i&lt;INT_MAX;i++)slot[i]=false;
          sort(arr,arr+n,myfunc);
          
          for(int i=0;i&lt;n;i++){
              int k=arr[i].dead;
              for(int t=k-1;t&gt;=0;t++){
                  if(slot[t]==false){
                      slot[t]=true;
                      answer.push_back(arr[i].id);
                      break;
                  }
              }
          }
          return answer;
       } 
  };
  </code></pre>
  <p><strong>error shown:</strong></p>
  <blockquote>
  <p>Solution::JobScheduling(Job*, int):<br />
  prog.cpp:41:30: error: invalid use of non-static member<br />
  sort(arr,arr+n,myfunc);</p>
  </blockquote>