//This here is just our bucket sort for the droids. Places each droid into a matching stack (I used a case structure based around the string instead of typing it) //after that, it gets put into a queue, for the sole purpose of showing that... I can write a queue. After that it gets put back into the array. //After some early issues I realized that it wasn't working properly due to data entry problems, so maybe using the Type to sort them would have worked better, //but by this time I had already finished it with strings. public void ModelSort(DroidQueue <IDroid> queue, DroidStack <IDroid> protocolStack, DroidStack <IDroid> janitorStack, DroidStack <IDroid> utilityStack, DroidStack <IDroid> astromechStack) { for (int counter = 0; counter < droidCollection.GetLength(0); counter++) { if (this.droidCollection[counter] != null) { switch (this.droidCollection[counter].Model) { case "Protocol": protocolStack.AddDroid(this.droidCollection[counter]); break; case "Astromech": astromechStack.AddDroid(this.droidCollection[counter]); break; case "Janitorial": janitorStack.AddDroid(this.droidCollection[counter]); break; case "Utility": utilityStack.AddDroid(this.droidCollection[counter]); break; } } } while (astromechStack.Size != 0) { queue.QueueDroid(astromechStack.RemoveDroid()); } while (janitorStack.Size != 0) { queue.QueueDroid(janitorStack.RemoveDroid()); } while (utilityStack.Size != 0) { queue.QueueDroid(utilityStack.RemoveDroid()); } while (protocolStack.Size != 0) { queue.QueueDroid(protocolStack.RemoveDroid()); } lengthOfCollection = 0; while (queue.Size != 0) { this.droidCollection[lengthOfCollection] = queue.UnQueueDroid(); lengthOfCollection++; } }