Skip to main content

A Python package for visualizing sorting algorithms

Project description

PopUpSort

With the assistance of ChatGPT-3.5, I was able to create this sorting visualizer.

The PopUpSort package is a Python package that visualizes multiple sorting algorithms. The package uses the Tkinter library for the graphical user interface.

Requirements

  • Python 3.x
  • tkinter library (included in most Python installations)

Installation

Method 1: Using pip

pip install popupsort

Method 2: Download the source code, then open terminal in the downloaded folder (where setup.py is) and run

pip install .

Usage

First import the package

import popupsort as pus

Syntax

pus.sort(array, algorithm, speed) # Sorting an already defined array

pus.sort_rand(size, min, max, algorithm, speed) # Auto generate an array and sort it

pus.sort_compare(array, algorithms, speed) # Compare sorting algorithms

pus.sort_compare_rand(size, min, max, algorithms, speed) # Auto generate an array and compare sorting algorithms

Algorithms

Replace 'algorithm' argument with any of these options:

  • 'Bubble Sort' or 'b'
  • 'Selection Sort' or 's'
  • 'Insertion Sort' or 'i'
  • 'Quick Sort' or 'q'
  • 'Merge Sort' or 'm'
  • 'Heap Sort' or 'h'
  • 'Shell Sort' or 'sh'

For sorting comparision, replace 'algorithms' argument with a list of algorithms:

algorithms = ['b', 's', 'i', 'q', 'm', 'h', 'sh'] # You can remove any algorithms you don't want to compare

Examples

arr = [60,24,21,65,93,56,35,10,55,49,86,76] # Define an array
pus.sort(arr, 'b', 0.02)                    # Visualize the bubble sort of this array with a speed of 0.02s

pus.sort_rand(50, 1, 100, 'i') # Generate an array of size 50 with elements ranging from 1 to 100 and sort it using insertion sort, speed is 0.01 by default

pus.sort_compare(arr, ['s','i']) # Compare selection and insertion algorithms

pus.sort_compare_rand(100, 1, 20, ['q','h','m']) # Generate an array and compare quick sort, heap sort, and merge sort

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

popupsort-1.6.tar.gz (6.2 kB view details)

Uploaded Source

File details

Details for the file popupsort-1.6.tar.gz.

File metadata

  • Download URL: popupsort-1.6.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for popupsort-1.6.tar.gz
Algorithm Hash digest
SHA256 27ba03640a1be275cc05b5022744655d3999304d4f857342c20c2ac0c09fde23
MD5 76919dfa79e2298b15987e7a4d7d50e4
BLAKE2b-256 3ee999d7e79a95c18bf5b1f70de595c984b27d9092a79e0a5d2ff101244b222b

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