So your methods will need to take a char[]
static int partition(char[] userInput, int start, int end)
static void quicksort(char[] userInput, int start, int end)
You will need to give them a char[]
// this is needed to have copy of the mutated array
var charArray = userInput.ToCharArray();
quicksort(charArray, 0, userInput.Length - 1);
You will need to change the for loop to char in case b
foreach (char s in charArray)
Your temp
variable in partition
will need to be a char
char temp;
And instead of string.Compare
you can just use greater than or less than
while (i < end && userInput[i] < userInput[pivot])
i++;
while (j > start && userInput[j] > userInput[pivot])
j--;
This disregards any other problem in your code, and only focuses on getting this to compile with a char array
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…