This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes Strings in alphabatic order Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Strings in alphabatic order" Watch "Strings in alphabatic order" New topic
Author

Strings in alphabatic order

Ashok Pradhan
Ranch Hand

Joined: Dec 17, 2007
Posts: 179

can we print a given string in alphabetic order of the character of that given string.
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

Originally posted by Ashok Pradhan:
can we print a given string in alphabetic order of the character of that given string.


Yeah sure, you can. Have you tried something and it did not work?
Just trying to find out whether you have read this FAQ entry: Show some effort


apigee, a better way to API!
James Bellan
Greenhorn

Joined: Nov 05, 2007
Posts: 9
Hi Ashok,

Here is the program you can use to sort the string.

[ code deleted - Jim ]

Cheers, J2G.
[ January 24, 2008: Message edited by: Jim Yingst ]
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

Well Navin,
We do not just post code if it looks like that there has been no effort shown before posting the code. This is a javaranch policy.
Using Collections.sort() or Arrays.sort() will give the desired result as the natural-ordering of strings is alphabetical.
Mark Newton
Ranch Hand

Joined: Jan 31, 2006
Posts: 129
...also, when you *do* post code, you'll find that the [code] tags make it much more readable, and therefore easier for the person you're trying to help, understand for next time...

You might like to review HowToAnswerQuestionsOnJavaRanch.
Ashok Pradhan
Ranch Hand

Joined: Dec 17, 2007
Posts: 179

Thanks to all.I solved it by using Array.sort().
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Strings in alphabatic order
 
Similar Threads
Order of Listeners
how to replace integer in agiven string
How to check StringArray is sorted or not?
Servlet Filters
String in alphabatic order