Solved

Sorting String[] with strings starting with capital letter and strings in lowercase

Posted on 2003-10-28
2
329 Views
Last Modified: 2012-08-14
Hi
Just as the title says..im trying to sort an array of strings. An example code follows :

String[] x = {"smithaj", "VMerve","albertd"};
Arrays.sort(x);

The output I get from this would be:
VMerve
albertd
smithaj

It sorts the strings starting with capital letters first.. The result I want is:
albertd
smithaj
VMerve

I donot want to change the way the data is ie. change all strings to lowercase/uppercase.
Is there a way it will sort the data with ignoring the case?

Thank you in adavance.
SB
0
Comment
Question by:ScarletBlue
  • 2
2 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 20 total points
ID: 9632880
Arrays.sort(x, String.CASE_INSENSITIVE_ORDER);
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9633022
:-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now