Skip to content
This repository has been archived by the owner on Oct 7, 2019. It is now read-only.

Up #185

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Up #185

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions sort/selection_sort/java/SelectionSort.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import java.util.Arrays;

public class SelectionSort {

public static void sort(int[] array) {

for (int i = 0; i < array.length; i++) {
int minor = i;
for (int j = i + 1; j < array.length; j++) {
if (array[j] < array[minor]) {
minor = j;
}
}
swap(array, i, minor);
}
}

private static void swap(int[] array, int i, int j) {
int aux = array[i];
array[i] = array[j];
array[j] = aux;

}

}