About 731,000 results
Open links in new tab
  1. Using a For Loop to Manually Sort an Array - Java

    Jan 12, 2016 · I'm having trouble manually sorting the array with a for loop. It works except for the first and last number. Here's my code: for(int j = 0; j < numbers.length - 1; j++) if(numbers[i] < …

  2. How to sort an array in a single loop? - GeeksforGeeks

    Jun 11, 2021 · Given an array of size N, the task is to sort this array using a single loop. How the array is sorted usually? There are many ways by which the array can be sorted in ascending …

  3. Java Arrays. sort() Method - W3Schools

    The sort() method sorts an array in ascending order. This method sorts arrays of strings alphabetically, and arrays of integers numerically.

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

    Apr 1, 2025 · Using For Loops: You can use for loops to traverse the array and compare adjacent elements while traversing and putting them in order. Using The Sort method: The Arrays class …

  5. How to Sort an Array in Java - Interview Kickstart

    Sep 25, 2024 · Numerical or lexicographical sorting of an array in ascending or descending order can be done with the help of in-built methods like sort () and reverseOrder (). If you want to …

  6. Sort the array in java - PrepInsta

    In this page we will discuss various algorithms to sort the given input array. Method 1 : Using naive approach. temp = arr[i]; . arr[i] = arr[j]; . arr[j] = temp; } } } //Displaying elements of array …

  7. Arrays.sort() in Java - GeeksforGeeks

    Apr 8, 2025 · The Arrays.sort() method is used for sorting the elements in an Array. It has two main variations: Sorting the entire array (it may be an integer or character array) Sorting a …

  8. Java Program to Sort an Array in Descending Order

    Mar 5, 2021 · In this approach, we will see how to use loops to sort an array in descending order. We can sort the array using manual sorting like using for loops. What we can do is use two for …

  9. How to Sort Array in Java: Ascending and Descending - Newtum

    Jul 8, 2023 · Sorting an Array Using the for loop. Below given Java code demonstrates a simple approach to sorting an array in descending order.

  10. How to sort an array in a single loop? - Stack Overflow

    Aug 12, 2015 · Sorting an array using java in Single Loop: public int[] getSortedArrayInOneLoop(int[] arr) { int temp; int j; for (int i = 1; i < arr.length; i++) { j = i - 1; if …

  11. Some results have been removed