Files
Tutoring-APCompSci/Sorting/WordSelectionSorter.java
2020-06-17 21:10:32 -05:00

23 lines
561 B
Java

package Sorting;
public class WordSelectionSorter extends WordSorter{
public WordSelectionSorter(RandomWordFileReader reader){
super("selection sort", reader);
}
void sort(){
for(int i=0;i<words.length-1;i++){
int currentMinIndex = i;
for(int j=i+1;j<words.length;j++){
int comp = compare(words[currentMinIndex],words[j]);
if(comp>0){
currentMinIndex = j;
}
}
swap(words,i,currentMinIndex);
}
}
}