Monday, August 8, 2011

Java: Sort the content of a string

Arrays of java.util is very useful for sorting and other stuffs. You can easily sort your String using the sort() function of that class. Below is the sample code.

String string = "String to sort";
char[] array = string.toCharArray();
string = new String(array);

Basically this simple piece of code is converting the string into a character array, and then sorting it and return back to the string again. Simple...!

No comments:

Get function name programaticaly - Python

This little piece of code will help you to get the function name programatically. This is very helpful when you are implementing the debug...