About 513,000 results
Open links in new tab
  1. Java Program to Sort an ArrayList - GeeksforGeeks

    May 17, 2021 · An ArrayList of Wrapper class object is nothing but an ArrayList of objects like String, Integers, etc. An ArrayList can be sorted in two ways ascending and descending order. The collection class provides two methods for sorting ArrayList. sort () and reverseOrder () for ascending and descending order respectively. 1 (A)Ascending Order

  2. How to sort ArrayList values by name in java - Stack Overflow

    Oct 20, 2011 · If you want it sorted by name, then why do you query for it sorted by date? Sorting it in the DB is definitely the better approach: "from Student order by name, date" should do it.

  3. Java.util.ArrayList.sort() sorting algorithm - Stack Overflow

    May 5, 2012 · I was looking at the source code of the sort () method of the java.util.ArrayList on grepcode. They seem to use insertion sort on small arrays (of size < 7) and merge sort on large arrays.

  4. java - How to sort a List/ArrayList? - Stack Overflow

    Apr 27, 2013 · Collections.sort allows you to pass an instance of a Comparator which defines the sorting logic. So instead of sorting the list in natural order and then reversing it, one can simply pass Collections.reverseOrder() to sort in order to sort the list in reverse order:

  5. Java Program to Sort Names in an Alphabetical Order

    Sep 15, 2022 · For, sorting names in an Alphabetical order there are multiple ways to sort the array, like using inbuilt Arrays.sort () method or using normal sorting algorithms like the bubble sort, merge sort. Here let’s use the bubble sort and inbuilt sort. Example: Input : Array[] = {"Sourabh", "Anoop, "Harsh", "Alok", "Tanuj"}

  6. Java ArrayList sort () Method - W3Schools

    Sort a list in alphabetical order: import java.util.ArrayList; public class Main { public static void main(String[] args) { ArrayList<String> cars = new ArrayList<String>();

  7. Java Sort a List - List Sorting - W3Schools

    In the previous chapters, you learned how to use two popular lists in Java: ArrayList and LinkedList, which are found in the java.util package. Another useful class in the java.util package is the Collections class, which include the sort() method for …

  8. Java ArrayList Sort: Ascending and Descending Order

    Aug 4, 2023 · Learn to sort Java ArrayList in ascending and descending order using ArrayList.sort (), Collections.sort (), Comparator interface and Java 8 Streams.

  9. How to Sort ArrayList in Java: A Step-by-Step Guide

    Nov 1, 2023 · TL;DR: How Do I Sort an ArrayList in Java? Java provides the Collections.sort() method to sort an ArrayList. This method sorts the ArrayList in ascending order, making it easier to manage and navigate through your data. Here’s a simple example: ArrayList<Integer> numbers = new ArrayList<>(Arrays.asList(5, 3, 8, 1)); Collections.sort(numbers);

  10. Java ArrayList sort () - Order Elements | Vultr Docs

    Nov 15, 2024 · In this article, you will learn how to use the sort() method effectively on ArrayList objects in Java. Discover methods to sort elements and explore the versatility of the sort() method by implementing it with various data types and custom sorting rules.

Refresh