Skip to content
murmot

Results for “sort array java example python site:geeksforgeeks.org code”

  • geeksforgeeks.org

    Merge Sort - GeeksforGeeks

    Merge sort is a popular sorting algorithm known for its efficiency and stability. It follows the Divide and Conquer approach. It works by recursively dividing the input array into two halves, recursively sorting the two halves and finally merging them back together to obtain the sorted array.

  • geeksforgeeks.org

    Pancake sorting - GeeksforGeeks

    Given an unsorted array, the task is to sort the given array. You are allowed to do only following operation on array.# Python3 program to # sort array using # pancake sort #.

  • geeksforgeeks.org

    Sorting in Java - GeeksforGeeks

    Apr 16, 2026 · Sorting in Java is used to arrange elements in a specific order (ascending or descending). It can be done using simple logic or Java’s built-in methods for better efficiency and readability. Can be performed using loops (manual sorting) Provides built-in methods like Arrays.sort () and Collections.sort () Works with arrays, lists, and other data structures Ways of sorting in Java 1. Using loops

  • geeksforgeeks.org

    TimSort - GeeksforGeeks

    Driver Code Ends. Python.Applications of Tim Sort: Used as the default sorting algorithm in Python (sorted(), list.sort()) and Java (from Java 7 onwards for Arrays.sort() on objects). Particularly effective for real-world datasets where data is often partially sorted.

  • geeksforgeeks.org

    How to Sort an Arrays of Object using Arrays.sort ()

    Jun 13, 2024 · To sort the array of objects in both ascending and descending order in Java, we can use the Arrays.sort () method with the Comparator. In this article, we will learn how to sort an array of objects using Arrays.sort ().

  • geeksforgeeks.org

    Bubble Sort - GeeksforGeeks

    Sorts the array using multiple passes. After the first pass, the maximum goes to end (its correct position).# Optimized Python program for implementation of Bubble Sort def bubbleSort(arr): n = len(arr) #. Traverse through all array elements for i in range(n)

  • geeksforgeeks.org

    Selection Sort - GeeksforGeeks

    # Python program for implementation of Selection # Sort. def selectionSort(arr): n = len(arr) for i in range(n - 1): # Assume the current position holds #.

  • geeksforgeeks.org

    Java Program to Sort Names in an Alphabetical Order

    Jul 23, 2025 · 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.

  • geeksforgeeks.org

    Nearly Sorted - GeeksforGeeks

    Sep 30, 2026 ... Directly sort the given array using the built-in sort() function. The array is rearranged in ascending order. C++ Java Python C# JavaScript.

  • geeksforgeeks.org

    Java Program to Sort the Elements of an Array in Ascending ...

    Aug 18, 2026 · Sorting an array in ascending order means arranging its elements from the smallest value to the largest value. In Java, an array can be sorted using the built-in Arrays.sort () method or by implementing a sorting algorithm such as Bubble Sort. Ascending order arranges elements from smallest to largest.