Skip to content

feat: add Strand Sort and fix sort_utils unused import warnings#1036

Merged
siriak merged 1 commit intoTheAlgorithms:masterfrom
AliAlimohammadi:add-strand-sort
Apr 17, 2026
Merged

feat: add Strand Sort and fix sort_utils unused import warnings#1036
siriak merged 1 commit intoTheAlgorithms:masterfrom
AliAlimohammadi:add-strand-sort

Conversation

@AliAlimohammadi
Copy link
Copy Markdown
Contributor

Description

Implements Strand Sort, a comparison-based sorting algorithm that works by repeatedly extracting increasing subsequences ("strands") from the input and merging them into a growing result list.

Algorithm:

  1. Remove the first element of the remaining input and start a new strand.
  2. Scan the rest of the input left-to-right; whenever an element is ≥ the last element of the strand, pull it out and append it to the strand. One full pass yields one sorted strand.
  3. Merge the strand into the accumulated result via a standard two-way merge.
  4. Repeat until the input is empty.

Also fixes pre-existing unused import warnings in sort_utils.rs by gating use rand::RngExt and use std::time::Instant with #[cfg(test)], matching the functions that use them.

Type of change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue) — unused import warnings in sort_utils.rs

Checklist

  • I ran cargo clippy --all -- -D warnings just before my last commit and fixed any issue that was found.
  • I ran cargo fmt just before my last commit.
  • I ran cargo test just before my last commit and all tests passed.
  • I added my algorithm to the corresponding mod.rs file within its own folder, and in any parent folder(s).
  • I added my algorithm to DIRECTORY.md with the correct link.
  • I checked CONTRIBUTING.md and my code follows its guidelines.

@AliAlimohammadi
Copy link
Copy Markdown
Contributor Author

@siriak, this is ready to be merged.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.91304% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 96.00%. Comparing base (2cb9392) to head (d98845c).

Files with missing lines Patch % Lines
src/sorting/strand_sort.rs 98.91% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1036   +/-   ##
=======================================
  Coverage   95.99%   96.00%           
=======================================
  Files         391      392    +1     
  Lines       29630    29722   +92     
=======================================
+ Hits        28444    28535   +91     
- Misses       1186     1187    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@siriak siriak merged commit e08f5a5 into TheAlgorithms:master Apr 17, 2026
7 checks passed
@AliAlimohammadi AliAlimohammadi deleted the add-strand-sort branch April 17, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants