Hey I need help with creating this program. It's supposed to take the values I've assigned in int[]A and put them into int[]C in order from least to greatest (for example, C[0] would be 1, C[1] would be 3, etc.) Yes, this is a homework problem, but I've been trying it for a while now. I don't expect the answer directly, just some guidance. This is what I have so far:
public class Sort{
public static void main(String [] args){
int[]A={3,7,8,1,4,9,10};
int[]C=sort(A);
for(int i=0;i<C.length;i++){
System.out.print(C[i] +",");
}
}
public static int[] sort(int[]A){
int[]C=new int[A.length];
int min=A[0];
for(int g=0;g<C.length;g++){
for(int i=1;i<C.length;i++){
if(A[i]<min){
min=A[i];
}
C[g]=min;
for(int z=0;z<C.length;z++){
if(A[z]==min){
A[z]=11;
}
}
return C;
}
}
return C;
}
}
I have "return C" twice because it kept giving me a "missing return statement" compile error. Thanks.