becurrie / py-sorts

Sorting algorithms with python.
MIT License
10 stars 2 forks source link
algorithm bogo bubble console console-application heap insertion merge py-sorts python python3 quick selection shuffle simple sort sort-integers sorting sorting-algorithm sorting-algorithms

GitHub version

py-sorts

Sort Integers using different sorting algorithms!

Getting Started

Check the releases section to find the latest working zip/tar.

python -m py_sorter [args]

Sorts Available

Sorts Available
Selection Merge Bogo
Bubble Quick Radix
Insertion Recursive Insertion Heap
Shell

Arguments

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

Examples

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

Caution

Installing

Development

Launching

Testing

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details

Resources

Sorting Algorithms

Argument Parsing