I have this project where I have to sort some txt files, most of them are numbers but one of them is a collection of months. I have the code that sorts the others but not the file containing the months. So i need this code to be changed so I can sort a string array any advice would be brilliant thank you!
public void SortArray(decimal[] numbers)
{
bool swap;
decimal temp;
do
{
swap = false;
for(int index = 0; index < (numbers.Length - 1); index ++)
{
if ( numbers[index] > numbers[index+1])
{
//swap
temp = numbers[index];
numbers[index] = numbers[index + 1];
numbers[index + 1] = temp;
swap = true;
}
}
} while (swap == true);
}
}
used this code... forgot some answered last time i tried this
If you have an string array like this:
The shorter way to sort it, using:
and the long way to sort it, using: