Skip to content

Commit

Permalink
fix: return when empty
Browse files Browse the repository at this point in the history
  • Loading branch information
genskyff committed Feb 15, 2024
1 parent 871d2fd commit 513e09e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/sorting/selection_sort.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
pub fn selection_sort<T: Ord>(arr: &mut [T]) {
if arr.is_empty() {
return;
}

let len = arr.len();
for left in 0..(len - 1) {
let mut smallest = left;
Expand Down

0 comments on commit 513e09e

Please sign in to comment.