Skip to content

Commit

Permalink
Refactored quicksort implementation to improve
Browse files Browse the repository at this point in the history
semantic
  • Loading branch information
Michael-Liendo committed Nov 12, 2023
1 parent cf20c53 commit 6b23e61
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/quicksort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ where
let mut greater_than_pivot: Vec<T> =
quicksort(&coll.iter().filter(|i| *i > pivot).cloned().collect());

// Start building the result with the elements less than the pivot
let mut result = less_than_pivot;

// Add the pivot to the result
result.push(*pivot);
// Add the elements greater than the pivot to the result
result.append(&mut greater_than_pivot);

result
Expand Down

0 comments on commit 6b23e61

Please sign in to comment.