Skip to main content

comptSort

A function designed to sort sequences of data with one of 5 different sorting algorithms: Bubble Sort, Insertion Sort, Binary Insertion Sort, Merge Sort and Quicksort.

>>> from comptSort import comptSort
>>> from comptSort import SortingAlgorithm
>>> uData = [9, 8, 7, 6, 5, 4, 3, 2, 1]
>>> sData = comptSort(uData, SortingAlgorithm.MERGE, asc=True)
>>> sData
[1, 2, 3, 4, 5, 6, 7, 8, 9]

Installation

python3 -m pip install comptSort

Usage

comptSort provides two functions, one that sorts a list in place, and one that returns a sorted copy of a list.

from comptSort import compSort
from comptSort import compSortInPlace

comptSort offers 5 different sorting algorithms, all of which are comparison sorts.

>>> from comptSort import SortingAlgorithm
>>> list(SortingAlgorithm)
[<SortingAlgorithm.BUBBLE: 'bubble'>, <SortingAlgorithm.INSERTION: 'insertion'>, <SortingAlgorithm.BIN_INSERTION: 'bin_insertion'>, <SortingAlgorithm.MERGE: 'merge'>, <SortingAlgorithm.QUICK: 'quick'>]

Command Line Interface

It is also possible to sort a file with the CLI.

$ comptSort -h
usage: comptSort [-h] [-a {bubble,insertion,bin_insertion,merge,quick}] [-d] [-i] [-o OUTPUT] file

Test the comptSort library by sorting lines of files.

positional arguments:
  file                  file containing items to sort

options:
  -h, --help            show this help message and exit
  -a {bubble,insertion,bin_insertion,merge,quick}, --algorithm {bubble,insertion,bin_insertion,merge,quick}
                        algorithm to sort with
  -d, --descending, --reverse
                        order sequence in descending order
  -i, --force-integers  parse lines from files as integers (by default strings)
  -o OUTPUT, --output OUTPUT
                        write sorted lines to file

Authorship

Jacob Sanchez Perez <jsanchez-perez@uclan.ac.uk>

License

GPLv2

This software is distributed under the General Public License v2.0, more information available at the Free Software Foundation.

Metadata

Release files for comptSort 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for comptSort 0.3.0
File Size Uploaded
comptSort-0.3.0.tar.gz 1.7 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for comptSort 0.3.0
File Interpreter ABI Platform
comptSort-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.7 MB

Release files / comptSort-0.3.0.tar.gz

Download URL comptSort-0.3.0.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
5c9d15fbd570331c718cc5a20fea1367225d4ad491ca3e7385a882e2d020390f
BLAKE2b-256 checksum
How to use checksums
55c1139a0e24325c5ff23759d16a11c177a333eb0198e2b18a5b21a86f617593
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.0

Release files / comptSort-0.3.0-py3-none-any.whl

Download URL comptSort-0.3.0-py3-none-any.whl
Size 22.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3027e41637878f33153466ecf0dde673686ddece6f24d6f685cfa651bd3221c3
BLAKE2b-256 checksum
How to use checksums
0ce50be9d4507c7d75fe9b8e9a26ae7df2e920f0c335de21916247a473c5e9ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.0

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page