Sort Integers using different sorting algorithms!
Check the releases section to find the latest working zip/tar.
python -m py_sorter [args]
Sorts Available | ||
---|---|---|
Selection | Merge | Bogo |
Bubble | Quick | Radix |
Insertion | Recursive Insertion | Heap |
Shell |
Argument | Description | Example |
---|---|---|
-s / --sort | type of sort being performed on list. | python -m py_sorter -s radix |
-i / --integers | provide a list of integers to be sorted. | python -m py_sorter -i 9 34 5 4 |
-g / --generate | generate a random list of integers to be sorted. | python -m py_sorter -g 1000 |
-l / --list | displays the original/sorted lists. | python -m py_sorter -l |
-a / --allsorts | perform sort on list with each algorithm, except bogo sort. | python -m py_sorter -a |
-c / --compare | display a time comparison between chosen sort and pythons default sorted() function. | python -m py_sorter -c |
python -m py_sorter -g 8 -s bogo -l -c
Output:
Shuffles: 63,257
Algorithm: [bogo]
Original List:
468, 846, 801, 976, 261, 641, 72, 698
Sorted List:
72, 261, 468, 641, 698, 801, 846, 976
Time(seconds) bogo: 0.3453168464965863
Time(seconds) sorted(): 3.5189852184980275e-06
bogo was 0.3453133275113678 seconds slower.
python -m py_sorter --generate 10000 --sort quick
Output:
Algorithm: [quick]
Time(seconds): 0.02490532463518387
Be careful when using the Bogo sorting algorithm, it shuffles an array and checks it's been sorted, shuffling infinitely until list is sorted. larger data sets will take a long time (forever).
Some algorithms use recursive sub routines to sort, this can lead to RecursionErrors if the data set is very large.
python setup.py install
.python -m py_sorter [args]
.python sorter-runner.py [args]
New tests can be added to the run_all.py
file located at (/tests).
To run automated tests:
python -m run_all
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE file for details