sort、stable_sort 与排序契约 | STL

本章覆盖:`std::sort`;random access iterator requirement;comparator;strict weak ordering;average / worst complexity 标准演进高层认知;`stable_sort`;stability;extra memory implementation trade-off;list 不支持 std::sort;custom struct sorting;面试不应只会 `sort(v.begin(), v.end())`。

本章知识点

  • std::sort
  • random access iterator requirement
  • comparator
  • strict weak ordering
  • average / worst complexity 标准演进高层认知
  • stable_sort
  • stability
  • extra memory implementation trade-off
  • list 不支持 std::sort
  • custom struct sorting
  • 面试不应只会 sort(v.begin(), v.end())