Sort by Even and Odd numbers

前端 未结 6 1021
故里飘歌
故里飘歌 2021-01-20 16:45

I would like to know is it possible to sort number by even or odd using the std::sort function.

I have the following codes but i am not sure how to implement in the

6条回答
  •  广开言路
    2021-01-20 17:02

    You can write a comparison function like

    bool evenOddLess( Point const& a, Point const& b )
    { return (isEven( a ) < isEven( b )); }
    

    Then you can use that as third argument to std::sort.

提交回复
热议问题