V
Vanessa
I am aware of the fact that C# has a sort option.
However, sometimes it is handy to have a sort
e.g. to sort a couple of arrays simultaneously.
The sort below works fine, except when I change
the < sign to a > sign, then one element gets missorted.
Could someone please put that right for me? Please (!)
indicate the code that should be changed, rather than
responding with a narrative. Many thanks.
using System;
using System.Collections;
namespace Sort
{
public class Sort
{
public static int[ ] integers(int [ ] arg1)
{
int I2 = arg1.Length, I3 = I2;
int temp1;
while ((I2 = I2 / 2) != 0)
{
int I4 = I3 - I2, I5 = 1;
do
{
int I6 = I5;
do
{
int I7 = I6 + I2;
if (arg1[I6] < arg1[I7])
break;
temp1 = arg1[I6];arg1[I6]=arg1[I7];arg1[I7]=temp1;
I6 = I6 - I2;
}
while (I6 > 0);
I5 = I5 + 1;
}
while (I5 < I4);
}
return arg1;
}
}
}
However, sometimes it is handy to have a sort
e.g. to sort a couple of arrays simultaneously.
The sort below works fine, except when I change
the < sign to a > sign, then one element gets missorted.
Could someone please put that right for me? Please (!)
indicate the code that should be changed, rather than
responding with a narrative. Many thanks.
using System;
using System.Collections;
namespace Sort
{
public class Sort
{
public static int[ ] integers(int [ ] arg1)
{
int I2 = arg1.Length, I3 = I2;
int temp1;
while ((I2 = I2 / 2) != 0)
{
int I4 = I3 - I2, I5 = 1;
do
{
int I6 = I5;
do
{
int I7 = I6 + I2;
if (arg1[I6] < arg1[I7])
break;
temp1 = arg1[I6];arg1[I6]=arg1[I7];arg1[I7]=temp1;
I6 = I6 - I2;
}
while (I6 > 0);
I5 = I5 + 1;
}
while (I5 < I4);
}
return arg1;
}
}
}