Views, sort_copy, online algorithms...
cpp-sort currently only cares about in-place sorting algorithms: algorithms that mutate the passed collection and don't return anything (except when they do), which is pretty much enough for people most of the time. However, I believe that there is some value in having algorithms that actually copy a sorted equivalent of the passed collection into the library. It once again leads to maaaaany design decisions depending on how we want to implement that:
- Have a
cppsort::sort_copyfunction in the library taking a sorter (or defaulting todefault_sorter) and an additionalOutputIteratorparameter? - Provide an equivalent
cppsort::sort_movefunction? - Create a
cppsort::sortedfunction that takes an iterable and returns a new instance of the same iterable? Make it work with anOutputIteratorinstead? Have it take any sorter likecppsort::sort? - Add a
cppsort::sorted_viewreturning a range with sorted iterators which, when iterated, corresponds to a sorted view of the original collection? It's pretty much whatindirect_adapterdoes in the first place, but decoupling it from the adapter might also be interesting. - Have first-class support for online sorting algorithm? Adding an
is_onlineproperty incppsort::sorter_traitsis easy, but how to use it properly?
An interesting algorithm about incremental sort that might provide some idea and/or insights about online/incremental sorting: http://larshagencpp.github.io/blog/2016/04/23/fast-incremental-sort