Skip to content

Conversation

@dabevlohn
Copy link

Sorting function

The file implements the bubble_sort function for sorting using the bubble sort algorithm.

The function takes a modifiable reference to a slice of elements and sorts it in ascending order.

If the array is empty, the function returns control immediately.

Inside the loop, the array is traversed, neighboring elements are compared, and if the current one is larger than the next, they are swapped.

If there were no permutations during the pass, the array is considered sorted and the loop is terminated.

After each complete pass, the range for the next iteration is decreased by 1 because the last element is already in its place.

Tests

The tests module implements tests for various cases:

  • Array sorted descending (descending)
  • Already sorted array (ascending)
  • Empty array (empty)
  • Long array of random numbers (long) - takes much time(!)
  • Array with negative numbers (negative)
  • Array with zero and negative numbers (withnull)
  • Array with duplicates (duplicate)

For each test it is checked that the result is really sorted and contains the same elements as the initial array (using the auxiliary functions is_sorted and have_same_elements).

some tests added
@dabevlohn dabevlohn requested review from imp2002 and vil02 as code owners June 26, 2025 09:03
@codecov-commenter
Copy link

codecov-commenter commented Jun 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.52%. Comparing base (ff55eda) to head (5500fd2).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #894   +/-   ##
=======================================
  Coverage   95.52%   95.52%           
=======================================
  Files         319      319           
  Lines       23014    23039   +25     
=======================================
+ Hits        21984    22009   +25     
  Misses       1030     1030           

☔ 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.

@github-actions
Copy link

This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Jul 27, 2025
@github-actions
Copy link

github-actions bot commented Aug 3, 2025

Please ping one of the maintainers once you commit the changes requested or make improvements on the code. If this is not the case and you need some help, feel free to ask for help in our Gitter channel. Thank you for your contributions!

@github-actions github-actions bot closed this Aug 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants