Could you give us your main method, or how those 2 methods you posted are used together ? I don't see what a method with integer arrays have anything to do with your problem, unless they're the letter number of in the alphabet of each letter.
Aviras
Junior Poster in Training
87 posts since Jul 2008
Reputation Points: 24
Solved Threads: 8
Skill Endorsements: 0
Next time, please copy & paste whatever compiler complains or error you got after running. Saying that you have trouble doing it doesn't really help anyone to understand your problem. Many of us do not have time to go through your code and look for error.
Anyway, get back to your code... in getUserInput() method line 11~15, I am not sure that your loop works correctly? How do you input a null value to the loop in order to exit the loop? You should set up a rule to exit the loop. In this case, you may say if the incoming value is equal to "q" or "quit" then you quit the loop.
In CountingSort() method line 22, you declare an array incorrectly. The array of integer should be declared as int[] C = new int[A.length].
Hmm... Actually after looking at the whole code in the method, you just copy & paste the pseudo code of the algorithm! Before I go any further, I must ask you to fix the syntax of "for" loop first...
Taywin
Posting Maven
2,633 posts since Apr 2010
Reputation Points: 275
Solved Threads: 375
Skill Endorsements: 17
I'm having trouble sorting names in alphabetical order using counting sort
Not surprising really - the counting sort algorithm is for sorting small integers (or objects keyed by small integer keys). Are you sure you are trying to do the right thing here?
ps This is a cross-post, please check the DaniWeb Member Rules.
http://stackoverflow.com/questions/7564973/name-sorting-using-counting-sort
JamesCherrill
... trying to help
8,527 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,456
Skill Endorsements: 30
Hmm... The person is trying to fish for an answer for codes... The person even ignored what I pointed out for the error/bug of the program...
I think the sort can still be done in this case. I have implemented the sort just to test it out and it worked. Though, I guess I will give up this post because of that cross-post. Let the other answers. ;)
Taywin
Posting Maven
2,633 posts since Apr 2010
Reputation Points: 275
Solved Threads: 375
Skill Endorsements: 17