Error on sumitting my code which works fine on other compiler

My code gives error when i submit >>>refrence to non static variable must be called in sort(arr.begin(),arr.end(),com) line in my code on leetcode ,but runs fine on other compilers .

public:
    unsigned int ones(int x)
{
    unsigned int count=0;
    while(x)
    {
    x&=x-1;
    count++;
    }
    return count;
}

bool com(int x,int y)//the way or parameter we want to sort ie number which will have less num of one will come first;
{
    return ones(x)>=ones(y)?0:1;
}

    vector<int> sortByBits(vector<int>& arr)  {
      
       sort(arr.begin(),arr.end(),com); // this line shows error ,
       
     return arr;
   }

    
};
Comments (0)