Skip to content

In this repository i posted some Sort Algorithms made with java.

Notifications You must be signed in to change notification settings

JuniorInjects/SortAlgorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sort Algorithms

List

Usage of the Sort Algorithms

public static void main(String[] args) {
		
	int arr[] = {5,3,8,2,1}; // This is the list of numbers to be sorted.
		
	String list = "";
	for (int i = 0; i < arr.length; i++) 
		list = list + " " + arr[i];
        
	System.out.println("Unsorted List: " + list); // Here you output the unsorted list in the console.
		
	ExampleSort sort = new ExampleSort(arr); // Here you give the algorithm the list.
	sort.sort(); // Here you sort the list.
		
	System.out.println("Sorted List: " + sort.get()); // Here you output the sorted list in the console.
}

Example with Bubble Sort

As an Example i will use Bubble Sort Algorithm.

public static void main(String[] args) {
		
	int arr[] = {5,3,8,2,1};
		
	String list = "";
        
	for (int i = 0; i < arr.length; i++)
		list = list + " " + arr[i];
        
	System.out.println("Unsorted List: " + list);
		
	BubbleSort sort = new BubbleSort(arr);
	sort.sort();
		
	System.out.println("Sorted List: " + sort.get());
}

The output in the console is

Unsorted List:  5 3 8 2 1
Sorted List:  1 2 3 5 8

About

In this repository i posted some Sort Algorithms made with java.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages