I want to sort a string in JAVA alphabetically, as follows Capital letter and lowercase letter followed AaBbCcDdEeFfGg. for example if I put AbaC return me AabC thanks!!
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Turn the String into a character array, then compare the int values of each character in your sort.
Methods needed:
String.toCharArray();
You can do this using
Arrays.sort
, if you put the characters into an array first. (It must be an array ofCharacter
objects rather thanchar
primitives, in order to use a custom case-insensitive comparator.)You may try to look for Collections.sort and then try like this:-
Something like this:-
EDIT:-
For sorting alphabetically in a string try like this:-