Sorting Algorithm Visualizer
This is a web-based Sorting Algorithm Visualizer built with HTML, CSS, and JavaScript (ES Modules). It supports multiple popular sorting algorithms with animations, color-coded bar movements, and interactive controls.
π Features
Visualizes: Bubble, Selection, Insertion, Merge, Quick, and Heap Sort
Adjustable speed via slider
Manual or random array input
Stop sorting at any time
Colored animations:
π΅ Unsigned bars
π§ Currently compared
π΄ Swapping
π¨ Pivot (Quick Sort)
π© Sorted bars
π Folder Structure
sorting-visualizer/ β βββ index.html βββ style.css βββ main.js βββ utils.js βββ algorithms/ βββ bubbleSort.js βββ selectionSort.js βββ insertionSort.js βββ mergeSort.js βββ quickSort.js βββ heapSort.js
π§ͺ How to Run in Chrome (Important!)
Modern browsers block type="module" scripts over file://, so you must use a local server.
β Option 1: Using Python
python -m http.server 5500
Then open:
β Option 2: VS Code + Live Server
Open folder in VS Code
Install "Live Server" extension
Right-click index.html β Open with Live Server
β Option 3: Node.js http-server
npm install -g http-server http-server -p 5500
Then visit:
π± Controls
Choose Algorithm: Dropdown to select sorting type
Input Box: Enter custom numbers (comma separated)
Generate Array: Creates a new random or user-defined array
Sort: Starts the animation
Stop: Halts animation immediately
Speed Slider: Controls delay between steps (lower = faster)
β Compatibility
Works in Chrome, Firefox, Edge
Make sure JavaScript is enabled
Must be served via HTTP protocol (local server)
π Credits
Made with β€οΈ by Arvind using vanilla JavaScript and DOM manipulation.
π License
This project is free to use and modify for personal or educational purposes.