0
I am trying to sort an array of names with this method, more when it has minuscule letter and Acentuo the names go to the end of the list, someone knows a method that sorts considering capital letters , minusculas , with accentuation ?
String nomes[] = { "Ana","aa","B" };
for (int i = 0; i < nomes.length - 1; ++i)
for (int j = i + 1; j < nomes.length; ++j)
if (nomes[i].compareTo(nomes[j]) > 0) {
String temp = nomes[i];
nomes[i] = nomes[j];
nomes[j] = temp;
}
To ignore the uppercase letters there is the
compareToIgnoreCase
.– Enzo Tiezzi
and the accent you know?
– Ilgner de Oliveira
In Java if you use an Arraylist you can sort with compareTo. http://www.tutorialspoint.com/java/java_using_comparator.htm
– Jorge B.
you can use the method itself
sort()
vector to do this.– Enzo Tiezzi
Ilgner Stackoveflow is not like other forums. Here the questions are not marked as answered.
– Jorge B.
In addition, asked the question for array of names, and the right answer is with array of names, if you want to know with Arraylist it would be better to create a new question.
– Jorge B.