Skip to main content

A Python package containing implementation of various sorting algorithms.

Project description

Sortify

Project Description


sortify is a Python package containing implementations of different sorting algorithms. This module is implemented using vanilla Python and does not need any additional dependencies.

Installation


Simply run the following command in the terminal to install sortify:

pip install sortify

Usage


The following example demonstrates how you can use sortify:

from sortify import Sort

if __name__ == "__main__":
    arr = [1, 7, 2, 6, 3, 5, 4]
    print(Sort.bubble(arr))

This prints the following result:

[1, 2, 3, 4, 5, 6, 7]

The available sorting methods are:

  • Sort.bubble(arr: list, reverse: bool) → Bubble sort
  • Sort.insertion(arr: list, reverse: bool) → Insertion sort
  • Sort.selection(arr: list, reverse: bool) → Selection sort
  • Sort.quick(arr: list, reverse: bool) → Quick sort
  • Sort.mergesort(arr: list, reverse: bool) → Merge sort

Here, set the parameter reverse = True to sort the list in descending order. For example:

from sortify import Sort

if __name__ == "__main__":
    arr = [1, 7, 2, 6, 3, 5, 4]
    print(Sort.merge(arr, reverse=False))

This prints the following result:

[7, 6, 5, 4, 3, 2, 1]

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

sortify-1.2.1.tar.gz (3.0 kB view hashes)

Uploaded Source

Supported by

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