Custom Comparator should help

Collections.sort(list, new Comparator<String>() {
    @Override
    public int compare(String s1, String s2) {
        return s1.compareToIgnoreCase(s2);
    }
});

Or if you are using Java 8:

list.sort(String::compareToIgnoreCase);
Answer from denis.solonenko on Stack Overflow
Discussions

java - How do I sort an ArrayList of strings by alphabetical order? - Stack Overflow
I'm trying to create a program that can sort the contents of an ArrayList alphabetically. Right now I have three classes in my program... Dog public class Dog { private String name; publ... More on stackoverflow.com
🌐 stackoverflow.com
java - Sorting an ArrayList of Objects alphabetically - Stack Overflow
I have to create a method that sorts an ArrayList of objects alphabetically according to email and then prints the sorted array. The part that I am having trouble with it sorting it. I have researc... More on stackoverflow.com
🌐 stackoverflow.com
How can I make an array list in alphabetical order?
I have an array list in a class that contains the main method, and I want to use Collection.sort (arrayName) way without I need to use another class or interfaces, is it More on sololearn.com
🌐 sololearn.com
17
4
sorting - Sort alphabetically ArrayList of Strings in java - Stack Overflow
I am trying to sort an ArrayList of strings. So far I have tried using ArrayList.sort but I am note sure how to use it properly. My class looks like this: ArrayList arraylist ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Coderanch
coderanch.com › t › 679208 › java › Sort-arraylist-alphabetical-order
Sort an arraylist by name in alphabetical order (Beginning Java forum at Coderanch)
April 29, 2017 - Rajith Pemabandu's code can be simplified if you don't need a case insensitive sort: And you can eliminate the ALPHABETICAL_ORDER method. Some other notes on the code: contactList should be initialized with a generic: The method name ALPHABETICAL_ORDER should be alphabeticalOrder by convention. All things are lawful, but not all things are profitable. ... Following this, I am to somehow get this arraylist to show up in a JList, but have no idea how to even begin that I've got a GUI window that shows up, and only have a very vague idea of how panels work, but that's about it.
🌐
Baeldung
baeldung.com › home › java › java list › sort a list alphabetically in java
Sort a List Alphabetically in Java | Baeldung
April 3, 2025 - We can also define our custom rules to sort alphabetically using java text.RuleBasedCollator.
🌐
W3Schools
w3schools.com › java › ref_arraylist_sort.asp
Java ArrayList sort() Method
If null is passed into the method then items will be sorted naturally based on their data type (e.g. alphabetically for strings, numerically for numbers). Non-primitive types must implement Java's Comparable interface in order to be sorted without a comparator. ... import java.util.ArrayList; public class Main { public static void main(String[] args) { ArrayList<String> cars = new ArrayList<String>(); cars.add("Volvo"); cars.add("BMW"); cars.add("Ford"); cars.add("Mazda"); cars.sort( (a, b) -> { return -1 * a.compareTo(b); } ); System.out.println(cars); } }
🌐
BeginnersBook
beginnersbook.com › 2013 › 12 › how-to-sort-arraylist-in-java
How to sort ArrayList in Java
Since this ArrayList is of string type, the elements are sorted in ascending alphabetical order. import java.util.*; public class JavaExample { public static void main(String args[]){ ArrayList<String> listOfCountries = new ArrayList<>(); listOfCountries.add("India"); listOfCountries.add("US"); listOfCountries.add("China"); listOfCountries.add("Denmark"); // Original unsorted list System.out.println("Before Sorting: "+ listOfCountries); //Sorting the ArrayList using sort() method ...
Find elsewhere
🌐
Career Karma
careerkarma.com › blog › java › learn to sort arraylist in java
Learn to Sort ArrayList in Java: A Step-by-Step Guide | Career Karma
December 1, 2023 - We declare a Java variable called students. Next, we add the student names to the ArrayList. We print the unordered list of student names, preceded by the message Student list:, to the console. Collections.sort() is performs a natural ordering operation that sorts the list.
🌐
Know Program
knowprogram.com › home › how to sort arraylist of strings alphabetically in java
How to Sort ArrayList of Strings Alphabetically in Java - Know Program
May 30, 2022 - For example:- list = [“Java”, ... To sort ArrayList of strings alphabetically in Java we can take help of Collections class sort() method....
🌐
W3Schools
w3schools.com › java › java_sort_list.asp
Java Sort a List - List Sorting
Sort a Java list alphabetically or numerically with Collections.sort().
🌐
Delft Stack
delftstack.com › home › howto › java › sort a list alphabetically in java
How to Sort a List Alphabetically in Java | Delft Stack
February 12, 2024 - The crux of the process involves using the List.sort() method directly on the list. This method facilitates alphabetical sorting, and a comparator is utilized for case-insensitive comparison.
🌐
Instanceofjava
instanceofjava.com › 2016 › 03 › how-to-sort-arraylist-of-strings.html
How to sort arraylist of strings alphabetically java - InstanceOfJava
March 10, 2016 - 1.Basic Java example program to sort arraylist of strings ... To sort an ArrayList object, use Collection.sort method.
🌐
DZone
dzone.com › data engineering › data › different approaches to sorting elements of an arraylist in java
Java ArrayList: Approaches to Sorting Elements
November 1, 2015 - This method will sort the elements (country names) of the ArrayList using natural ordering (alphabetically in ascending order). Lets’s write some code for it. package guru.springframework.blog.sortarraylist.ascendingdescending; import java.util.ArrayList; import java.util.Collections; public class SortArrayListAscendingDescending { private ArrayList<String> arrayList; public SortArrayListAscendingDescending(ArrayList<String> arrayList) { this.arrayList = arrayList; } public ArrayList<String> getArrayList() { return this.arrayList; } public ArrayList<String> sortAscending() { Collections.sort(this.arrayList); return this.arrayList; } public ArrayList<String> sortDescending() { Collections.sort(this.arrayList, Collections.reverseOrder()); return this.arrayList; } } In the class above, we initialized an ArrayList object in the constructor.
🌐
Stack Overflow
stackoverflow.com › questions › 40683335 › sort-alphabetically-arraylist-of-strings-in-java
sorting - Sort alphabetically ArrayList of Strings in java - Stack Overflow
For the String Double Integer you can use Collection.sort(). It directly modifies the arraylist you pass instead of returning a new arraylist.
🌐
Medium
medium.com › @AlexanderObregon › sorting-text-alphabetically-with-java-code-177cfc072947
Sorting Text Alphabetically with Java Code | Medium
July 26, 2025 - The built-in comparator handles basic case-insensitive sorting, but Java lets you take it further by writing your own comparison logic. That’s where lambda expressions come in. With lambdas, you can write sorting rules that match your exact needs without creating separate classes or interfaces. Here’s how to use a lambda to do case-insensitive sorting: List<String> team = new ArrayList<>(); team.add("Zach"); team.add("alex"); team.add("Brian"); team.add("liam"); team.sort((a, b) -> a.compareToIgnoreCase(b)); System.out.println(team);
🌐
Javatpoint
javatpoint.com › how-to-sort-arraylist-in-java
How to Sort ArrayList in Java - javatpoint
How to Sort ArrayList in Java with java tutorial, features, history, variables, object, class, programs, operators, for-loop, oops concept, inheritance, array, string, map, math, methods, examples etc.