About 6,080,000 results
Open links in new tab
  1. Sorting in Java - GeeksforGeeks

    Mar 15, 2024 · In Java, sorting an array consists of arranging the elements in a particular order, such as ascending or descending. This can be achieved using various algorithms like Bubble Sort, Selection Sort, or Insertion Sort. A menu-driven program allows users to select the desired sorting method dynamically.

  2. Arrays.sort() in Java - GeeksforGeeks

    Apr 8, 2025 · To sort an array of strings in descending alphabetical order, the Arrays.sort () method combined with Collections.reverseOrder () method and it arranges the strings from Z to A based on lexicographical order. We can sort an array of objects by defining custom sorting logic with the help of using the Comparator interface. Explanation:

  3. Java Program for QuickSort - GeeksforGeeks

    Jan 31, 2025 · Program to Implement Quick Sort in Java. Complexity of the above Program: Auxiliary Space: O (N) in the worst case and O (Log n) on average. Mainly the extra space required is for recursion call stack and the worst case happens when one part is always empty. Please refer complete article on QuickSort for more details!

  4. Java How To Sort an Array - W3Schools

    You can use the sort() method, found in java.util.Arrays, to sort an array: Example import java.util.Arrays; public class Main { public static void main(String[] args) { String[] cars = {"Volvo", "BMW", "Tesla", "Ford", "Fiat", "Mazda", "Audi"}; Arrays.sort(cars); for (String i : cars) { System.out.println(i); } } }

  5. Java Sorting Programs for Interview 2025 - Javacodepoint

    Sorting is a fundamental concept in Java programming and is frequently asked in technical interviews. It helps in organizing data efficiently, making search and retrieval operations faster. In this article, we will cover basic to advanced sorting techniques in Java , including both manual implementations and built-in sorting methods .

  6. How to Sort an Array, List, Map or Stream in Java - HowToDoInJava

    Learn to sort a Java Set, List and Map of primitive types and custom objects using Comparator, Comparable and new lambda expressions.

  7. How to Sort an Array in Java 8 - Java Guides

    In Java 8, you can sort arrays using the Arrays.sort() method for basic sorting in ascending order, or you can use Streams for more flexibility, including sorting in descending order. Both approaches are efficient and easy to implement, and you …

  8. How to Sort an Array in Java? - Tpoint Tech

    Mar 17, 2025 · In Java, Arrays is the class defined in the java.util package that provides sort () method to sort an array in ascending order. It uses Dual-Pivot Quicksort algorithm for sorting. Its complexity is O (n log (n)). It is a static method that parses an array as a parameter and does not return anything. We can invoke it directly using the class name.

  9. How To Sort An Array In Java – Tutorial With Examples

    Apr 1, 2025 · In this tutorial, we will discuss the sorting of Arrays in detail along with simple examples. Java provides the following methods to sort the arrays. Using For Loops: You can use for loops to traverse the array and compare adjacent elements while …

  10. Sorting Arrays in Java - HowToDoInJava

    Feb 4, 2022 · Learn to sort a Java array of primitives, strings and custom objects in multiple ways with the help of Comparable and Comparator interfaces, Arrays.sort() and Stream.sorted() APIs. We will learn to sort arrays in natural ordering, reverse ordering and any other custom ordering as …

Refresh