Skip to content

Commit

Permalink
fix: remove unneeded code
Browse files Browse the repository at this point in the history
  • Loading branch information
genskyff committed Feb 15, 2024
1 parent 6759fe7 commit 871d2fd
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/sorting/selection_sort.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
pub fn selection_sort<T: Ord>(arr: &mut [T]) {
let len = arr.len();

if len < 2 {
return;
}

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

for right in (left + 1)..len {
if arr[right] < arr[smallest] {
smallest = right;
}
}

if left != smallest {
arr.swap(left, smallest);
}
arr.swap(smallest, left);
}
}

Expand Down

0 comments on commit 871d2fd

Please sign in to comment.