rename to distinguish btw number and word sorters

This commit is contained in:
2020-06-17 16:50:25 -05:00
parent fdca76f02a
commit 0daafbe767
9 changed files with 25 additions and 25 deletions

View File

@@ -0,0 +1,21 @@
package Sorting;
public class NumberSelectionSorter extends NumberSorter {
//a class to sort an array of numbers using selection sort
public NumberSelectionSorter(RandomNumberFileReader reader){
super("selection sort", reader);
}
void sort(){
for(int i=0;i<numbers.length-1;i++){
int currentMinIndex = i;
for(int j=i+1;j<numbers.length;j++){
int comp = compare(numbers[currentMinIndex],numbers[j]);
if(comp>0){
currentMinIndex = j;
}
}
swap(i,currentMinIndex);
}
}
}