how to sort an array without using sort method in java

Solutions on MaxInterview for how to sort an array without using sort method in java by the best coders in the world

showing results for - "how to sort an array without using sort method in java"
Fares
24 Jun 2016
1// How to sort an array without using sort method in java
2public class WithoutUsingSortMethod
3{
4   public static void main(String[] args) 
5   {
6      int temp;
7      int[] arrNumbers = {14, 8, 5, 54, 41, 10, 1, 500};
8      System.out.println("Before sort: ");
9      for(int num : arrNumbers)
10      {
11         System.out.println(num);
12      }
13      for(int a = 0; a <= arrNumbers.length - 1; a++)
14      {
15         for(int b = 0; b <= arrNumbers.length - 2; b++)
16         {
17            if(arrNumbers[b] < arrNumbers[b + 1])
18            {
19               temp = arrNumbers[b];
20               arrNumbers[b] = arrNumbers[b + 1];
21               arrNumbers[b + 1] = temp;
22            }
23         }
24      }
25      System.out.println("After sort: ");
26      for(int num : arrNumbers)  
27      {
28         System.out.println(num);
29      }
30   }
31}
queries leading to this page
sorting array without sorting algorithm in javasort array with null elements in java without sort methodhow to sort an array in java without using sort methodhow to sort an array in java without using collectionssort array in java in decreasing order without sort methodhow to sort integer array in java without using sort methodsort int array java without using sort methodarray sorting without sort method in javasort an array without collection javahow to sort an array without using sort method and without using new array in javasort array without using inbuilt method in javasorting in java without using sort functionjava sort 5b 5d without using java utilhow to sort an array without using the sort methodsort array without using variables javasort array with null elements in java without sort functionsort array in java without sort method with o 28n 29how to sort string array without using sort method in java o 28n 29sort an array without using sort methodhow to sort array in java without sort methodhow to sort in array without sort methodsort array without using sort function javasort arraylist java without using sort methodsorting without using sort method javajava sort array without using sorthow to sort an array without using sort method in javasort array in java without sort methodsorting without using the sort methodsort array in descending order java without sort methodsort without sort function javasort array in java without sort methodsort an array without using inbuilt function in javahow to sort string array without using sort method in javalist sort in ascending order java without using sort methoddifferent ways to sort an array in java without using collectionssort an array without using sort method in javajava array sort ascending without sort methodsort array java without using sort method javahow to sort string array in java without using sort methodhow to sort an array without methodsgiven an array return a sorting array java without array sorthow to sort array without using sort method in javasorting array without sort method javasorting without sort function javahow to sort an array without using sort methodhow to sort an array without using sort method in java