Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorts from all around the web #23

Open
7 of 19 tasks
Morwenn opened this issue Nov 12, 2015 · 7 comments
Open
7 of 19 tasks

Sorts from all around the web #23

Morwenn opened this issue Nov 12, 2015 · 7 comments

Comments

@Morwenn
Copy link
Owner

Morwenn commented Nov 12, 2015

cpp-sort already uses sorting algorithms from all around the web (pdqsort, spreadsort, timsort, etc...); adding more of them in the long run can't be that harmful. Smart people created many interesting sorting algorithms and it would be a waste not to try them all. Here is a list of interesting projects that we could use to complete the library:

There are probably even more interesting sorting algorithms around. However, adapting them is often not trivial. For example SqrtSort uses 3-way comparisons and C-isms all over the place, Exact-Sort mixes IO operations with the sorting logic, some of the algorithms simply don't have an implementation in C++... Adapting these algorithms implies that we have to adapt them to use an iterator interface, to add support for arbitrary comparison functions (or even projections) and to make them work with move-only types when possible. The sort::parallel library will probably be an interesting way to test the integration of parallel sorting algorithms in cpp-sort; floki would be a way to integrate SIMD algorithms in the library.

Reminder: ask the authors for the license when needed.

Morwenn added a commit that referenced this issue Nov 23, 2015
Add a smooth_sorter to the library (issue #23).
@Morwenn
Copy link
Owner Author

Morwenn commented Nov 23, 2015

Pull request #29 adds Keith Schwartz's implementation of Dijkstra's smoothsort to the library, slightly enhanced to support projection parameters and 64-bit architectures.

Morwenn added a commit that referenced this issue Nov 24, 2015
Add a block_sorter to the library (issue #23).
@Morwenn
Copy link
Owner Author

Morwenn commented Nov 24, 2015

Pull request #33 adds BonzaiThePenguin's WikiSort to the library, which is an implementation of Pok-Son Kim and Arne Kutzner's block sort algorithm. The implementation has been enhanced to support projection parameters.

Pull request #37 actually turns the resulting block_sorter into a buffered sorter. It makes it possible to choose how the buffer is allocated and therefore to reproduce what the different complie-time switches of the original code did, but without using the preprocessor, without altering the algorithm, and with a more extensive design.

Morwenn added a commit that referenced this issue Nov 27, 2015
Add an exact_sorter to the library (issue #23).
@Morwenn
Copy link
Owner Author

Morwenn commented Nov 27, 2015

Pull request #34 adds Ahmet Akkök's Exact-Sort to the library, enhanced to actually perform a minimal number of move operations and to support user-provided comparison and projection functions.

In the end, Exact-Sort seemed to be but an optimization over cycle sort. Commit 06ce9b5 kills exact_sorter and replaces it with a different sorting algorithm named mountain sort. It is implemented as a sorter adapter.

Commit 3aff41a changes the name mountain_adapter to indirect_adapter which should be clearer to most. I also realized that there is an equivalent algorithm in sort::parallel. It seems that it also performs a minimal number of move operations.

Morwenn added a commit that referenced this issue Dec 15, 2015
Add a grail_sorter to the library (issue #23).
@Morwenn
Copy link
Owner Author

Morwenn commented Dec 15, 2015

Pull request #41 adds Mrrl's GrailSort to the library as a buffered sorter (making it easy to also have SqrtSort when needed), which is an implementation of a stable sorting algorithm described by B-C. Huang and M. A. Langston. The implementation has been ported to C++ and enhanced to work with random-access iterators and to support comparison and projection parameters.

@Morwenn Morwenn added the future label Feb 22, 2016
Morwenn added a commit that referenced this issue Jan 10, 2017
Add a ska_sorter to the library (issue #23)
@Morwenn
Copy link
Owner Author

Morwenn commented Jan 10, 2017

Pull request #95 adds Malte Skarupke's ska_sort to the library as a type-specific sorter, adding support for proxy iterators, a bit of standard compliance regarding reinterpretation of a floating point number into an integer, and a few compile-time checks to make sure that the sorter will only accept the types it is able to handle, causing a substitution failure otherwise.

@Morwenn
Copy link
Owner Author

Morwenn commented Jan 15, 2017

Pull request #98 adds Adrian Wielgosik's C++ implementation of a drop-merge sort to the library, improving it with the following features:

  • Support for non-default-constructible types
  • Support for proxy iterators
  • Support for projections
  • Support for bidirectional iterators

The implementation was later simplified a bit, and a bug due to a self-move with non-trivially copyable types was fixed.

@Morwenn
Copy link
Owner Author

Morwenn commented Feb 2, 2020

cpp-sort 1.6.0 adds Francisco José Tapia's spinsort from Boost.Sort to the library, improving it with the usual things (projections, proxy iterators, etc.).

It's worth noting that I got rid of a bunch of calls to check whether a collection is sorted or reverse-sorted that didn't seem worth keeping: I don't want to pay two O(n) operation to handle two very specific cases that are already fast enough without dedicated checks anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant