Observed since 20 Oct, 19:06 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
An enhanced adaptive sorting algorithm with pattern detection
A novel sorting algorithm that combines multiple sorting strategies with pattern detection and parallel processing capabilities. This algorithm is particularly efficient for certain types of data patterns and provides stable sorting guarantees.
The algorithm shows different performance characteristics for various input patterns:
| Pattern | Performance vs NumPy | Best Use Case |
|---|---|---|
| Reversed | 0.51x | Large reversed sequences |
| Random | 0.09x | General purpose sorting |
| Few Unique | 0.08x | Data with many duplicates |
| Nearly Sorted | 0.02x | Almost sorted data |
| Pipeline | 0.02x | Streaming data patterns |
pip install adaptive-hybrid-sort
# Clone the repository
git clone https://github.com/valEn1Ob0/adaptive-hybrid-sort.git
# Navigate to the directory
cd adaptive-hybrid-sort
# Install the package
pip install -e .
# Setup the environment
sorts setup
The package provides a convenient command-line interface through the sorts command:
sorts setup
sorts sort --size 1000 --pattern random
Available patterns: random, nearly_sorted, reversed, few_unique, sorted, pipeline
sorts benchmark --sizes 1000 2000 4000 --patterns random nearly_sorted --runs 3
The benchmark results will be saved in a timestamped directory under sorting_results/.
from adaptive_hybrid_sort import EnhancedAdaptiveSort
# Create a sorter instance
sorter = EnhancedAdaptiveSort()
# Sort an array
arr = [64, 34, 25, 12, 22, 11, 90]
sorted_arr = sorter.sort(arr)
# Custom thresholds for different array sizes
sorter = EnhancedAdaptiveSort(
threshold_small=32, # Threshold for insertion sort
threshold_chunk=2048 # Threshold for chunk size
)
# Sort different types of data
# Integers
int_arr = [1000, 1, 100, 10]
sorted_ints = sorter.sort(int_arr)
# Floats
float_arr = [3.14, 1.41, 2.71, 1.73]
sorted_floats = sorter.sort(float_arr)
from adaptive_hybrid_sort import SortingVisualizer
# Create visualizer
visualizer = SortingVisualizer()
# Run benchmarks
sizes = [1000, 10000, 100000]
patterns = ["random", "nearly_sorted", "reversed", "few_unique", "sorted", "pipeline"]
results = visualizer.benchmark_sorting(sizes, patterns)
# Generate visualizations
visualizer.plot_performance_comparison(results)
The algorithm uses statistical sampling to detect patterns in the input data:
Adapts its strategy based on input characteristics:
Array Size
Data Patterns
Memory Usage
Contributions are welcome! Here are some areas for improvement:
MIT License - see the LICENSE file for details.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 1.0.0 | 10 Feb 2025 | 7 |
This describes our collected data; it is not a security assessment.
Shared repository data · GitHub
Observed since 20 Oct, 19:06 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:d4302f73a0abc1feccd57c8a7d437b1d39788130bba92266bd5979e4c387c100