Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8365493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:40:16+00:00 2026-06-09T12:40:16+00:00

I have a problem in comparing strings.I want to compare two éd and ef

  • 0

I have a problem in comparing strings.I want to compare two “éd” and “ef” french texts like this

Collator localeSpecificCollator = Collator.getInstance(Locale.FRANCE);
CollationKey a = localeSpecificCollator.getCollationKey("éd");
CollationKey b = localeSpecificCollator.getCollationKey("ef");
System.out.println(a.compareTo(b));

This will print -1, but in french alphabet e come before é. But when we compare only e and é like this

Collator localeSpecificCollator = Collator.getInstance(Locale.FRANCE);
CollationKey a = localeSpecificCollator.getCollationKey("é");
CollationKey b = localeSpecificCollator.getCollationKey("e");
System.out.println(a.compareTo(b));

result is 1. Can you tell we what is wrong in first part of code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:40:18+00:00Added an answer on June 9, 2026 at 12:40 pm

    This seems to be the expected behaviour and it also seems to be the correct way to sort alphabetically in French.

    The Android javadoc gives a hint as to why it is behaving like that – I suppose the details of the implementation in android are similar, if not identical, to the the standard JDK:

    A tertiary difference is ignored when there is a primary or secondary difference anywhere in the strings.

    In other words, because your 2 strings are sortable by only looking at primary differences (excluding the accents) the collator does not check the other differences.

    It seems to be compliant with the Unicode Collation Algorithm (UCA):

    Accent differences are typically ignored, if the base letters differ.

    And it also seems to be the correct way to sort alphabetically in French, according to the wikipedia article on “ordre alphabetique”:

    En première analyse, les caractères accentués, de même que les majuscules, ont le même rang alphabétique que le caractère fondamental
    Si plusieurs mots ont le même rang alphabétique, on tâche de les distinguer entre eux grâce aux majuscules et aux accents (pour le e, on a l’ordre e, é, è, ê, ë)

    In English: the order initially ignores accents and case – if 2 words can’t be sorted that way, accents and case are then taken into account.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with comparing two arraylist, my first arraylist looks like this:
Hey I have a problem comparing the value of a CGPoint (struct with two
I have an android app. in that I am comparing two strings from the
I have a rather weird problem: How do I compare strings (using Python )
I have two strings both with value null . But when I am comparing
I have a problem with the is operator comparing generic types. public interface ISomeInterface<T>
The problem is this: I have multiple competing threads (100+) that need to access
I have problem with my query on C, I’m using the oci8 driver. This
I have a problem that consist in comparing boolean expressions ( OR is +,
I have this string that has illegal chars that I want to remove but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.