Good day guys, I am trying to sort here using an array, Check my codes
public int[] Sort(int[] arr) {
int[] value = arr;
int min, temp, out;
for (out = 0; out < value.length - 1; out++) {
for (min = out + 1; min < value.length; min++) {
if(value[out] > value[min]){
temp = value[min];
value[min] = value[out];
value[out] = temp;
}
}
}
return value;
}
The problem here is I pass the array 'arr' value to the array 'value' and sort the 'value' array then the output is what i expect, he sorted the number, but the problem is, when i tried to return the 'arr' array it also return a sorted value even though i didn't tried to sort it .. is it a bug or just my ugly coding ?