From d0e3dc212ea7d855bf5339a5f9904e681e7b363a Mon Sep 17 00:00:00 2001 From: jacksonfu14 Date: Tue, 11 Nov 2025 08:12:01 +0100 Subject: feat: add sort with segregated sequence lengths --- morphology/README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'morphology/README.md') diff --git a/morphology/README.md b/morphology/README.md index dee8c3e..31c1e16 100644 --- a/morphology/README.md +++ b/morphology/README.md @@ -88,6 +88,9 @@ SortingMethod::BreadthFirst // Compare all outer values first, then all inner SortingDirection::Forward // Compare sequences from first to last position SortingDirection::Backward // Compare sequences from last to first position +LengthSorting::InterpolateLength // Sequences of different lengths sorted together by content +LengthSorting::SegregateLength // Sequences grouped by length, shorter sequences first + sort_sequences(&mut sequences, outer_order, inner_order) ``` @@ -168,7 +171,7 @@ let all_sets = generate_valid_sets(5); ```rust use meta_affine::{ValidSet, Value, Sequence}; use meta_affine::sequence::{generate_sequences, generate_all_sequences, sort_sequences}; -use meta_affine::sequence::{SequenceOptions, PrecedenceOrder, SortingMethod, SortingDirection}; +use meta_affine::sequence::{SequenceOptions, PrecedenceOrder, SortingMethod, SortingDirection, LengthSorting}; // Create a valid set let set = ValidSet::new() @@ -177,11 +180,12 @@ let set = ValidSet::new() // Generate all valid sequences of length 3 from this set let mut sequences = generate_sequences(&set, 3); -// Sort with defaults (Forward, DepthFirst, IncreasingPositiveFirst) +// Sort with defaults (InterpolateLength, Forward, DepthFirst, IncreasingPositiveFirst) sort_sequences(&mut sequences, None); // Sort with custom options using builder pattern let opts = SequenceOptions::new() + .length_sorting(LengthSorting::SegregateLength) .sorting_direction(SortingDirection::Backward) .sorting_method(SortingMethod::BreadthFirst) .outer_order(PrecedenceOrder::IncreasingNegativeFirst) @@ -190,6 +194,7 @@ sort_sequences(&mut sequences, opts); // Generate all sequences from all valid sets with sorting options let opts = SequenceOptions::new() + .length_sorting(LengthSorting::SegregateLength) .sorting_method(SortingMethod::BreadthFirst) .sorting_direction(SortingDirection::Backward); let all_sequences = generate_all_sequences(3, opts); -- cgit v1.2.3