Skip to main content

a package to aid user in implementing various sorting algorithms

Project description

pysorting

Documentation Statusci-cd codecov

Overview

This Python package provides an interactive and educational platform for understanding popular sorting algorithms. Designed for students and educators, it includes implementations of four key sorting algorithms. The package is simple to use and highly customizable, making it an excellent tool for learning and teaching sorting concepts.

Contributors

  • Chukwunonso Ebele-muolokwu
  • Marek Boulerice
  • Shashank Hosahalli Shivamurthy
  • Siddarth Subrahmanian

Features

  • bubble_sort: -This function takes in a list of numbers provided by the user and sorts it following a bubble-sort algorithm. A simple, comparison-based sorting algorithm that repeatedly swaps adjacent elements if they are in the wrong order.
  • insertion_sort: -This function takes in a list of numbers provided by the user and sorts it following a insertion-sort algorithm. A straightforward algorithm that builds the sorted array one element at a time.
  • quick_sort: -This function takes in a list of numbers provided by the user and sorts it following a quick-sort algorithm. Implements the divide-and-conquer sorting algorithm that partitions the array around a pivot element.
  • shell_sort: -This function takes in a list of numbers provided by the user and sorts it following a shell-sort algorithm. A generalization of insertion sort that allows the exchange of far-apart elements to improve performance.

Time Complexity Measurement

The library allows users to measure the time complexity of a specific sorting function. This helps in optimizing code by choosing the most suitable sorting algorithm for different use cases. For example

  • Bubble Sort is efficient for small datasets.
  • Insertion Sort performs well for iterables that are partially sorted.

This feature ensures users can make informed decisions about algorithm selection based on their dataset characteristics.

Comparing Sorting Algorithms

The library provides functionality to compare the performance of two or more sorting functions. By passing in a list, the function identifies and returns the fastest sorting algorithm for the given dataset. This is particularly useful for benchmarking and optimizing your code.

Checking if a list is sorted

A convenient helper function is included to verify if a list is sorted. It takes a list as input and returns a boolean value:

  • True if the list is sorted.
  • False otherwise.

This utility is handy for debugging and ensuring the correctness of sorting implementations.


The package was created with the goal to be a tool for aspiring computer and data scientists to use in order to better understand the steps, similiraities and differences of various sorting functions. With the current functions included, a user can easily pass an array and implement a sorting function of his choosing to return the sorted array. Further developments for this package will include a function to generate a random list of desired size for sorting, one function to compute the big-o complexity of a given sorting algortithm, and a visualization of the sorting process for a chosen algorithm.

pysorting in the Python Ecosystem

There are many presences of similar sorting functions within the python ecosystem. For one, python itself already has a built in .sort() function. There is also a sorted() built-in function that builds a new sorted list from an iterable.Additionally, several packages have also been created with similar goal of implementing various sorting algortithms. One example project is shown here: https://pypi.org/project/sort-algorithms/ Our package aims to distinguish itself from other packages through its easy access to auxiliary tools making it easy to implement various sorting algorithm, and importantly to highlight differences between them.

Installation

pip install pysorting

Usage

The following examples illustrate how the sorting functions in this package are intended to be used. Please note that the functions are currently not implemented—only their docstrings are in place for now.

After installing the package, you can import the functions (once implemented) as follows:

from pysorting import quick_sort, bubble_sort, shell_sort, insertion_sort

bubble_sort([4, 2, 7, 1, 3], ascending = False)

For more examples on usage of the different functions,you can check out this Example NoteBook

Contributing

Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

License

pysorting was created by Nonso, Marek, Siddarth, Shashank. It is licensed under the terms of the MIT license.

Credits

pysorting was created with cookiecutter and the py-pkgs-cookiecutter template.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysorting-0.0.2.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysorting-0.0.2-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file pysorting-0.0.2.tar.gz.

File metadata

  • Download URL: pysorting-0.0.2.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pysorting-0.0.2.tar.gz
Algorithm Hash digest
SHA256 60ad199b04d5b72d0b3b2ae2cb1e2927a51c6194ec6c7204c8fe28383813b485
MD5 33662de64baf73e318490fe547dc937e
BLAKE2b-256 ca8c51bdcb21fb48f0ec037f1e327823eed390eeebffb83908739323a2216012

See more details on using hashes here.

File details

Details for the file pysorting-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pysorting-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pysorting-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f4f8b36fc5b2973e0d113b52359bc52dcd94f361934cbff9684ea8f9f2911c2a
MD5 d0348c42d946e41f4f7bc58997ada5ab
BLAKE2b-256 37a7683783c8ab1a9765dcfddbacf4dcc04627fbbf93e70ee233ab69001b4039

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page