Array Sorting
First a little about me. I'm a GSP student at Devry near the end of my first year of a three year degree. I'm working a head of my class and am about four weeks ahead right now. In week 4 we are going to be covering arrays which we covered in my last class but we will and in object arrays. While reading up I came up with an idea for a different way to sort arrays and was very suprised by the results. The main reason for posting here is to see what is wrong with my code and if there are any ways to improve up on it. My results show that on large arrays that my sort way out performs the default C# sort which I have been told is Quick Sort, one of the better sorting methods out there.
Please I would like feedback, negative or postive.
classFlagSorter
{
// Fieldsint _optimizerUnknown = 20;int _optimizerKnown = 25;// Accessorspublicint optimizerUnknown{
get {return _optimizerUnknown; }set { _optimizerUnknown =value; }}
publicint optimizerKnown{
get {return _optimizerKnown; }set { _optimizerKnown =value; }}
// Methodspublicvoid sort(int[] arrayToSort){
int[] trackerArray;int largestInt = 0;int index = arrayToSort.Length - 1;foreach (int findLargestin arrayToSort)if (findLargest > largestInt)largestInt = findLargest;
//exit//exitif (largestInt < index * _optimizerUnknown){
trackerArray =
newint[largestInt + 1];foreach (int numberin arrayToSort)trackerArray[number] += 1;
//exitfor (int i = 0; i <= largestInt - 1; i++){
while (trackerArray[i] > 0){
arrayToSort[index] = i;
trackerArray[i]--;
index--;
}
i++;
}
}
elseArray.Sort(arrayToSort);}
publicvoid sort(int[] arrayToSort,int maxValue){
int[] trackerArray;int largestInt = maxValue;int index = arrayToSort.Length - 1;if (largestInt < index * _optimizerKnown){
trackerArray =
newint[largestInt + 1];foreach (int numberin arrayToSort)trackerArray[number] += 1;
//exitfor (int i = 0; i <= largestInt - 1; i++){
while (trackerArray[i] > 0){
arrayToSort[index] = i;
trackerArray[i]--;
index--;
}
i++;
}
}
elseArray.Sort(arrayToSort);}
}

