Frontend implementation of common sorting algorithms, including examples, performance metrics, implementation ideas, and algorithm visualization
π Online Demo | π Algorithm Details
- π― 10+ Sorting Algorithms: Covers classic algorithms including bubble sort, quick sort, selection sort, insertion sort, shell sort, merge sort, heap sort, counting sort, bucket sort, and radix sort
- π Performance Testing: Real-time display of algorithm execution time, supports different data scales (20, 5000, 10000, 50000)
- π¨ Algorithm Visualization: Each algorithm comes with GIF animation demonstrations for intuitive understanding of the execution process
- π‘ Implementation Ideas: Detailed explanation of the core concepts and implementation steps for each algorithm
- π Array Deduplication: Provides 3 different array deduplication implementation methods
- π Zero Dependencies: Pure vanilla JavaScript implementation, no frameworks or libraries required
Visit the online demo to experience it directly.
-
Clone the repository
git clone https://github.com/clayz/usualSortAlgorithm.git cd usualSortAlgorithm -
Start a local server (Python recommended)
# Python 3 python -m http.server 8000 # Or use Python 2 python -m SimpleHTTPServer 8000
-
Open in browser Visit
http://localhost:8000/index.html
| Algorithm | Time Complexity | Space Complexity | Stability | Description |
|---|---|---|---|---|
| Bubble Sort | O(nΒ²) | O(1) | β Stable | Compare and swap adjacent elements |
| Bubble Sort (Optimized) | O(nΒ²) | O(1) | β Stable | Uses flag to mark early termination |
| Selection Sort | O(nΒ²) | O(1) | β Unstable | Selects minimum element each time |
| Insertion Sort | O(nΒ²) | O(1) | β Stable | Suitable for small-scale or nearly sorted data |
| Algorithm | Time Complexity | Space Complexity | Stability | Description |
|---|---|---|---|---|
| Quick Sort | O(n log n) | O(log n) | β Unstable | Divide and conquer, most widely used in practice |
| Merge Sort | O(n log n) | O(n) | β Stable | Divide and conquer, preferred for stable sorting |
| Heap Sort | O(n log n) | O(1) | β Unstable | Utilizes heap data structure |
| Shell Sort | O(n^1.3) | O(1) | β Unstable | Improved version of insertion sort |
| Algorithm | Time Complexity | Space Complexity | Stability | Description |
|---|---|---|---|---|
| Counting Sort | O(n + k) | O(k) | β Stable | Suitable for integers with small range |
| Bucket Sort | O(n + k) | O(n + k) | β Stable | Efficient when data is uniformly distributed |
| Radix Sort | O(d(n + k)) | O(n + k) | β Stable | Sorts by digits, suitable for integers |
- Temporary Array Method: Uses
indexOfto check if element already exists - HashMap Method: Leverages object property uniqueness
- IndexOf Method: Determines first occurrence through position index
- Frontend Framework: Vanilla JavaScript (ES5+)
- UI Framework: Material Design Lite
- Styling: CSS3
- Visualization: GIF animations (Source: Visualgo.net)
The project provides an intuitive interactive interface that supports:
- Generate random arrays of different scales
- Select different sorting algorithms
- View sorting results and execution time in real-time
- View algorithm visualization animations
- Learn algorithm implementation ideas
Visit the online demo for more visualization animations
- Algorithm Fundamentals: Sorting is one of the most fundamental problems in computer science
- Interview Essential: Common topic in technical interviews at major companies
- Performance Optimization: Understand the appropriate scenarios for different algorithms to optimize real-world projects
- Thinking Training: Develop algorithmic thinking and problem-solving skills
- β Visual Learning: Intuitively understand algorithm execution through GIF animations
- β Performance Comparison: Real-time testing of different algorithms' performance at various data scales
- β Code Implementation: Complete JavaScript implementation for each algorithm
- β Idea Explanation: Detailed explanation of core concepts and steps for each algorithm
The project supports performance testing on arrays of different scales:
- Small Scale (20 elements): Suitable for observing algorithm execution process
- Medium Scale (5000 elements): Test basic algorithm performance
- Large Scale (10000, 50000 elements): Compare algorithm performance on large datasets
β οΈ Note: Large-scale data testing may take a long time, please be patient.
usualSortAlgorithm/
βββ index.html # Main page
βββ css/
β βββ algorithm.css # Stylesheet
βββ js/
β βββ algorithm.js # Sorting algorithm implementations
β βββ algorithm-idea.js # Algorithm idea explanations
βββ img/ # Algorithm visualization GIF images
βββ stylesheets/ # Third-party stylesheets
βββ README.md # Project documentation
Issues and Pull Requests are welcome!
If you have new sorting algorithm implementations, performance optimization suggestions, or bug fixes, contributions are welcome.
This project is licensed under the MIT License.
Clay
- GitHub: @clayz
- Online Demo: http://clayz.top/Algorithm/index.html
- Algorithm visualization GIFs source: Visualgo.net
- UI Framework: Material Design Lite
If this project is helpful to you, please give it a β Star!


