G
Guest
How is it possible to sort an array of ints using a for loop?
I recently tried the suggestion a newsgroup user offered on how to perform
this, but find that it doesn't work. He suggested the code below:
int[] list = new int[5]{12,1,105,99,66};
int length = list.GetLength(0)-1;
for (int i=0;i<length
{
if (list > list[i+1])
{
int a=list[i+1];
list[i+1]=list;
list=a;
if (i>0)
i--;
}
else
i++;
}
The output i get though is:
1,99,66,66
I'd love to find how to get this to work. It's nuts and bolts programming,
that I ought to know.
cheers,
CR
I recently tried the suggestion a newsgroup user offered on how to perform
this, but find that it doesn't work. He suggested the code below:
int[] list = new int[5]{12,1,105,99,66};
int length = list.GetLength(0)-1;
for (int i=0;i<length
{
if (list > list[i+1])
{
int a=list[i+1];
list[i+1]=list;
list=a;
if (i>0)
i--;
}
else
i++;
}
The output i get though is:
1,99,66,66
I'd love to find how to get this to work. It's nuts and bolts programming,
that I ought to know.
cheers,
CR