suffixsort
A high-performance Rust library for inverse lexicographic (suffix) sorting, providing both high-level processing utilities and low-level comparison functions.
Features
- Inverse Lexicographic Sorting: Compare strings from the last character towards the first
- Flexible Configuration: Multiple sorting modes including dictionary order, case insensitivity, and reverse sorting
- High Performance: Parallel processing using Rayon for handling large datasets efficiently
- Dual API: Both high-level line processing and low-level comparator functions
- Zero-Cost Abstractions: Minimal performance overhead through Rust's zero-cost abstractions
Installation
Add to your Cargo.toml:
[]
= ">=0.1"
Usage
High-Level API
The main entry point is the SortConfig struct which allows you to configure and execute the sorting process:
use ;
let config = SortConfig ;
let lines = vec!;
let = config.process_lines;
for line in processed
Low-Level API
For advanced use cases, you can use the comparator function directly:
use SortConfig;
use Ordering;
let config = SortConfig ;
let comparer = config.get_comparer;
let mut words = vec!;
// Use with standard sort
words.sort_by;
// Or with parallel sort (requires Rayon)
use *;
words.par_sort_by;
Configuration Options
The SortConfig struct provides these options:
ignore_case: Case-insensitive comparisonuse_entire_line: Use entire line instead of first word for sortingdictionary_order: Ignore non-alphabetic characters when finding first wordreverse: Reverse the sort orderstable: Use stable sorting algorithmright_align: Right-align output with paddingexclude_no_word: Exclude lines without wordsword_only: Output only the word used for sorting
Performance
The library is designed for high performance with large datasets:
- Parallel processing using Rayon's work-stealing scheduler
- Zero-copy operations where possible
- Efficient character-by-character comparison
- Minimal memory allocation
Examples
See the ssort binary crate for a complete CLI implementation using this library.
License
MIT OR Apache-2.0