B
B
bobs322021-04-09 15:14:49
Java
bobs32, 2021-04-09 15:14:49

Is there an alternative to the compareToIgnoreCase method?

Good afternoon!
When applying the compareToIgnoreCase method to strings:

String1 = "AAA";
String2 = "ААА1";
String1. compareToIgnoreCase(String2) // результат отрицательный (-975) то есть String2 идет лексикографически раньше String1.


Is there a method that will return a positive result (put String1 before String2)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2021-04-09
@bobs32

String.CASE_INSENSITIVE_ORDER.reversed().compare("AAA", "AAA1")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question