At the very least there needs to be some quick algorithm for sorting integers and reals. But I think we can implement several algorithms and the user can choose.
This will also be needed to implement #38.
Is it also an option to link to the algorithms provided by BLAS/LAPACK?
@jvdp1 I think so. We'll need to depend on Lapack for #10 anyway.
Here are inefficient implementations from fortran-utils: https://github.com/certik/fortran-utils/blob/b43bd24cd421509a5bc6d3b9c3eeae8ce856ed88/src/sorting.f90, the API however might be useful to get inspiration from. Here is more efficient implementation of quicksort: https://github.com/certik/hfsolver/blob/b4c50c1979fb7e468b1852b144ba756f5a51788d/src/sorting.f90#L165. I think there will be much better implementations out there, including in Lapack.
Here is a mutli-threaded one:
https://balsoftware.net/index.php/open-source/multi-thread-sort/
Not sure what is the license.
The following routines implement the version of quicksort outlined in Hanson's and Hopkins book and on the associated web site (http://www.siam.org/books/ot134). The publishers license is very permissive (at least as I read it). This version supports REAL32, REAL64, INT8, INT16, INT32, INT64, Character strings and arrays, and a user defined type. Unfortunately, the file tool for this page does not know anything about .f90 or .F90 file extensions. Here is the code:
Main quicksort module: type specific routines are overloaded with generic qsort interface. Sorting can be in place or return a integer permutation array leaving original array untouched. Sorting can be in either ascending or descending order.
A base user class that can be extended to define user specific classes. Specifies dummy methods for relational operators needed for sorting etc, a print method and an assignment method.
A test program that tests sorting integers, reals, characters, and a user point class that is sorted on distance (Euclidean Norm)
The point class used in test program. It is extended from the base User class
Here are some of mine:
A few more:
ipsort, isort, spsort, ssort, dpsort, dsort, and hpsort)qsort
Most helpful comment
A few more:
Sorting routines in various libraries
ipsort,isort,spsort,ssort,dpsort,dsort, andhpsort)Various user routines
Internet forums and discussion boards
Interfaces to C
qsortPublished works