Solved

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

Posted on 2003-10-28
2
317 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

705 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

20 Experts available now in Live!

Get 1:1 Help Now