Chaining of ordering predicates (e.g. for std::sort)

前端 未结 6 1828
说谎
说谎 2021-02-05 23:33

You can pass a function pointer, function object (or boost lambda) to std::sort to define a strict weak ordering of the elements of the container you want sorted.

Howeve

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-06 00:30

    std::sort is not guaranteed to be stable because stable sorts are usually slower than non-stable ones ... so using a stable sort multiple times looks like a recipe for performance trouble...

    And yes it's really a shame that sort ask for a predicate: I see no other way than create a functor accepting a vector of tristate functions ...

提交回复
热议问题