Simple Sort Demo : Sort Search : Collections Data Structure : Java examples (example source code) Organized by topic

Java
C++
PHP


Java  »  Collections Data Structure   » [  Sort Search  ]  Screenshots 
 



Simple Sort Demo



/* From http://java.sun.com/docs/books/tutorial/index.html */

public class SortDemo {
    public static void main(String[] args) {
        int[] arrayOfInts = 32873589121076,
                              20008622127 };

        for (int i = arrayOfInts.length; --i >= 0) {
            for (int j = 0; j < i; j++) {
                if (arrayOfInts[j> arrayOfInts[j+1]) {
                    int temp = arrayOfInts[j];
                    arrayOfInts[j= arrayOfInts[j+1];
                    arrayOfInts[j+1= temp;
                }
            }
        }

        for (int i = 0; i < arrayOfInts.length; i++) {
            System.out.print(arrayOfInts[i" ");
        }
        System.out.println();
    }
}

           
       
Related examples in the same category
1.  A simple applet class to demonstrate a sort algorithm
2.  Sorting an array of Strings Sorting an array of Strings
3.  Simple version of quick sort Simple version of quick sort
4.  Combine Quick Sort Insertion Sort Combine Quick Sort Insertion Sort
5.  Quick sort with median-of-three partitioning Quick sort with median-of-three partitioning
6.  Selection sort Selection sort
7.  Insert Sort for objects Insert Sort for objects
8.  Insert sort Insert sort
9.  Bubble sort Bubble sort
10.  Merge sort Merge sort
11.  Binary Search Binary Search
12.  Shell sort Shell sort
13.  Topological sorting Topological sorting
14.  Heap sort Heap sort
15.  Sort Numbers Sort Numbers
16.  A quick sort demonstration algorithm A quick sort demonstration algorithm
17.  Customized Sort Test
























Home| Contact Us
Copyright 2003 - 07 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.