Skip to content

Chores/sorting refactoring#4

Merged
Alexanderlacuna merged 2 commits intomainfrom
chores/sorting-refactoring
Mar 4, 2025
Merged

Chores/sorting refactoring#4
Alexanderlacuna merged 2 commits intomainfrom
chores/sorting-refactoring

Conversation

@Alexanderlacuna
Copy link
Copy Markdown
Owner

@Alexanderlacuna Alexanderlacuna commented Mar 4, 2025

This pull request (PR) addresses two issues:

  • Correctly handles sorting for floats involving NaN values fixing the error below
warning: `correlation_rust` (lib) generated 2 warnings (run `cargo fix --lib -p correlation_rust` to apply 1 suggestion)
    Finished `release` profile [optimized] target(s) in 3.36s_rust(bin)                                   
     Running `target/release/correlation_rust /tmp/correlation/37Q4IPvWda.json`
thread 'main' panicked at core/src/slice/sort/shared/smallsort.rs:860:5:
user-provided comparison function does not correctly implement a total order
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
  • Refactors code to eliminate a double sorting bug

By implementing these changes, the PR ensures accurate sorting of floating-point numbers, including proper handling of NaN values, and enhances performance by removing redundant sorting operations.

- Place NaNs at the end of the list.
- Sort positive infinity (`f64::INFINITY`) before finite numbers.
- Sort negative infinity (`f64::NEG_INFINITY`) after finite numbers.
- Add tests for negative numbers, NaN, and Infinity cases.
@Alexanderlacuna Alexanderlacuna merged commit d7b1fd6 into main Mar 4, 2025
1 check failed
@Alexanderlacuna Alexanderlacuna deleted the chores/sorting-refactoring branch March 4, 2025 13:45
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.

1 participant