In this post, we will learn about the **Sorting algorithms in java**. There are various sorting algorithm in java that you can implement. we have cover the major algorithms that are mostly used and asked.

## Sorting Algorithms

Sorting algorithms can be defined as a process of arranging the array elements in a way that they are either in ascending order or descending order. The most-used orders are numerical order and lexicographical order.

**For example:**

Consider the array: **int **Arr[10] = { 10, 4, 5, 2, 20, 35, 34, 17, 9, 14)**Now this array sorted in descending order will look like as given below:****int **Arr[10] = { 2, 4, 5, 9, 10, 14, 17, 20, 34, 35}

## Sorting in Java

There are various sorting algorithms in java which of some important are listed and are explained one by one. These various **sorting techniques in java** are also frequently asked in java interview questions.

**The list of types of sorting in java includes the following:**

These are indexes of top sorting algorithms in java with examples, click on the solution to understand each of the algorithms.

**1.** **Bubble Sort**

Bubble sorting is the simplest sorting algorithm that works by comparing two adjacent elements in an array and swapping them if found in the wrong order.*Explanation with Example.*

**2. Selection Sort**

The selection sort is a simple sorting algorithm which is an in-place comparison-based algorithm. It has two parts where the left end has a sorted part and the right end has an unsorted part.*Explanation with Example.*

**3. Heap Sort**

Heap is a tree in heap sorting that possesses some specific properties whose value should be greater than or equal to that of the children node.*Explanation with Example.*

**4. Insertion Sort**

Insertion sort is a simple sorting algorithm that sorts the elements in an array by comparing the values at index with all its prior elements. This process takes **more time** so it is only used for small data set.*Explanation with Example*

**5. Quick Sort**

Quick sort algorithm is a way of rearranging the elements in an array in ascending or descending order. Quicksort is another Divide and Conquer algorithm.** Explanation with Example**.

**6. Merge Sort**

Merge Sort is another sorting algorithm that follows a **Divide and Conquer** algorithm approach to sort the elements in an array in ascending or descending order.*Explanation with Example.*

**7. Shell Sort**

Shell sort is an **in-place** comparison-based sorting algorithm and variation of Insertion sort. It is a better version of Insertion sort in comparison-based. It can compare the elements far apart whereas Insertion compares adjacent elements.*Explanation with Example*

**8. Counting Sort**

Counting Sort Algorithm is an integer-based algorithm, non-comparison, and linear sorting algorithm. The counting sort algorithm sorts the elements in an array in a specific range. It is based on keys between the specific range.*Explanation with Example.*

If want to learn more Java Programming and improve your theoretical Knowledge, click on link below.