cmp中<与-之间的区别

问题遇到的现象和发生背景

leetcode刷题中cmp用bool <可以而int -不行,有什么区别吗

问题相关代码,请勿粘贴截图
//这个为啥不行啊leetcode905把偶数排前面
class Solution {
public:
    static int cmp (int a, int b) {
        return a%2<b%2;
      
    }
    vector<int> sortArrayByParity(vector<int>& a) {
        sort (a.begin(), a.end(), cmp);
        return a;
    }
};

运行结果及报错内容 、

这是错误的

img

这是正确的

img

我的解答思路和尝试过的方法
我想要达到的结果

bool类型中0为false非0为true,用int转换为bool时c++中cmp的sort看0 1,c语言中cmp的qsort看正负

sort函数对比较函数的格式是有要求的