Skip to content
murmot

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

  • geeksforgeeks.org

    Sort Array - GeeksforGeeks

    Oct 25, 2026 ... Inbuilt Function - O(n log n) Time · C++: sort(arr.begin(), arr.end()) · Java: Arrays.sort(arr); · Python: arr.sort() · JavaScript: arr.sort((a, b) ...

  • 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

    Sorting in Java - GeeksforGeeks

    Apr 16, 2026 ... sort() works for arrays which can be of primitive data type also which in turn by default sorts in ascending order. Example 1.

  • geeksforgeeks.org

    Pancake sorting - GeeksforGeeks

    Pancake sorting. Last Updated : 23 Jul, 2025. Given an unsorted array, the task is to sort the given array. You are allowed to do only following operation on array.

  • geeksforgeeks.org

    Bubble Sort - GeeksforGeeks

    # Optimized Python program for implementation of Bubble Sort def bubbleSort(arr): n = len(arr) #. Traverse through all array elements for i in range(n): swapped = False #.

  • geeksforgeeks.org

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

    Jun 13, 2024 · Sorting Objects according to name : { { Alice , 30} , { Bob ,25 } , { Charlie , 35 } } Programs for Sorting an Array of Objects Using Arrays.sort (): Below is the example using the custom Person class and sorting an array in both ascending order and descending order.

  • 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

    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

    sort() in Python - GeeksforGeeks

    Jan 3, 2018 · The sort () method in Python is used to arrange the elements of a list in a specific order. It works only on lists, modifies the original list in place, and does not return a new list. Example: This example shows the most basic use of sort () to arrange numbers in ascending order.