suffixsort 0.2.0

Library for suffix (inverse lexicographic) sorting
Documentation
  • Coverage
  • 4.76%
    1 out of 21 items documented1 out of 5 items with examples
  • Size
  • Source code size: 27.59 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.21 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 22s Average build duration of successful builds.
  • all releases: 23s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • suffixsort/suffixsort
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • hex48

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:

[dependencies]
suffixsort = ">=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 suffixsort::{SortConfig, ProcessedLine};

let config = SortConfig {
    ignore_case: true,
    reverse: false,
    dictionary_order: true,
    // ... other configuration options
    ..Default::default()
};

let lines = vec![
    "Apple".to_string(),
    "banana".to_string(),
    "Cherry".to_string(),
];

let (processed, padding_info) = config.process_lines(lines);

for line in processed {
    println!("{}", line.original);
}

Low-Level API

For advanced use cases, you can use the comparator function directly:

use suffixsort::SortConfig;
use std::cmp::Ordering;

let config = SortConfig {
    ignore_case: true,
    reverse: false,
    ..Default::default()
};

let comparer = config.get_comparer();
let mut words = vec!["Banana", "apple", "Cherry"];

// Use with standard sort
words.sort_by(|a, b| comparer(a, b));

// Or with parallel sort (requires Rayon)
use rayon::prelude::*;
words.par_sort_by(|a, b| comparer(a, b));

Configuration Options

The SortConfig struct provides these options:

  • ignore_case: Case-insensitive comparison
  • use_entire_line: Use entire line instead of first word for sorting
  • dictionary_order: Ignore non-alphabetic characters when finding first word
  • reverse: Reverse the sort order
  • stable: Use stable sorting algorithm
  • right_align: Right-align output with padding
  • exclude_no_word: Exclude lines without words
  • word_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