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 7537679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:54:59+00:00 2026-05-30T06:54:59+00:00

I want to sort an ArrayList<String> but the problem is my native language characters

  • 0

I want to sort an ArrayList<String> but the problem is my native language characters – my alphabet is like this: a, ą, b, c, č, d, e, f ... z, ž. As you see z character is second from the end and ą is second in alphabet, so after I sort my array it is sorted incorrectly. All my native language characters are moved to the end of array. Example:

package lt;

import java.util.ArrayList;
import java.util.Collections;

public class test {
    public static void main(String[] args) {
        List<String> items = new ArrayList<>();
        items.add("bbc");
        items.add("ąbc");
        items.add("abc");
        items.add("zzz");

        System.out.println("Unsorted: ");
        for(String str : items) {
            System.out.println(str);
        }

        Collections.sort(items);
        System.out.println();

        System.out.println("Sorted: ");
        for(String str : items) {
            System.out.println(str);
        }
    }
}

Output:

Unsorted: 
bbc
ąbc
abc
zzz

Sorted: 
abc
bbc
zzz
ąbc

Should be:

Sorted:
abc
ąbc
bbc
zzz
  • 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-05-30T06:55:00+00:00Added an answer on May 30, 2026 at 6:55 am

    You should use Collator class.

    For example

    Locale lithuanian = new Locale("lt_LT");
    Collator lithuanianCollator = Collator.getInstance(lithuanian);
    

    And then sort the collection using this collator

    Collections.sort(theList, lithuanianCollator);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three array lists with String .I want to sort one arraylist and
Just a minor problem with Arraylist . I want to sort a ArrayList<Client> by
i am having a string arraylist 'names'.which contains names of people.i want to sort
i want to sort dictionary based upon value of each dictioanry item.but if i
I want to sort a String that has nr. How do I do that?
I want to sort a list of strings based on the string length. I
Basically what I mean is like this: List<String[]> routes = (List<String[]>)application.getAttribute(routes); For the above
What is the best way to sort an ArrayList<String[]> in Java? Where String[] is...
I want to sort items where the comparison is performed by humans: Pictures Priority
I want to sort on a certain column only for rows containing a certain

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.