Hybrid-adaptive sorting framework for numbers, words, alphanumeric, and mixed data — plus a demo pipeline for container data classification (commercial vs non-commercial).
- Bucket detection: number, word, alnum, other.
- Natural sorting for mixed strings (e.g.,
A2 < A10). - Flexible bucket priority and per-bucket order (asc/desc).
- Stable (leverages Python's stable
sorted()). - CLI to sort TXT and CSV by column.
- Demo script: categorize containers and sort with multi-field keys.
# 1) Run CLI on a txt file
python cli.py samples/mixed_items.txt --output samples/mixed_sorted.txt
# 2) Run CLI on CSV by column (by name)
python cli.py samples/containers_sample.csv --column container_id --output samples/containers_sorted_by_id.csv
# 3) Run demo pipeline (classify + multi-key sort)
python categorize_and_sort_containers.pyfrom rasengan_sort import rasenggan_sort, RasenganSort
items = ["B12","apple","42","zebra","123","banana","A1","b2","99","Komersial","NonKomersial"]
print(rasenggan_sort(items))
# -> [42, 99, 123, 'apple', 'banana', 'Komersial', 'NonKomersial', 'zebra', 'A1', 'B12', 'b2']
sorter = RasenganSort(priority=["word","number","alnum","other"], order="asc")
print(sorter.sort(items)) ┌──────────────────────────┐
│ Start │
└─────────────┬────────────┘
▼
┌──────────────────────────┐
│ Ingest Raw Data │
└─────────────┬────────────┘
▼
┌──────────────────────────┐
│ Detect Type per Item │
│ (number/word/alnum/other)│
└─────────────┬────────────┘
▼
┌──────────────────────────┐
│ Sort per Bucket with │
│ best strategy │
└─────────────┬────────────┘
▼
┌──────────────────────────┐
│ Merge by Priority │
└─────────────┬────────────┘
▼
┌──────────────────────────┐
│ Optional Categorization │
│ (e.g., commercial vs │
│ non-commercial) │
└─────────────┬────────────┘
▼
┌──────────────────────────┐
│ Output Clean & Sorted │
└──────────────────────────┘
- "Rasenggan Sort" here is a practical prototype, not a new theoretical lower-bound algorithm.
- You can extend
categorize_and_sort_containers.pywith better NLP/ML classification.