I was trying to use a sort algorithm according to our programming lecture. Maybe I am just missing something.
I would appreciate it if someone may help me out or could give me a hint about any mistake I made.
Here my current code:
package Sortieralgorithmus;
public class sort {
public static int[] straightSelection(int[] numbers) {
for (int i = 0; i < numbers.length; i++) {
int smallestIndex = i;
for (int j = i + 1; j < numbers.length; j++) {
if (numbers[i] < numbers[smallestIndex]) {
smallestIndex = j;
}
}
swap(j, i, numbers);
}
return numbers;
}
}
swapdefined anywhere? You have mixed upi,j, andsmallestIndexin two places.