Showing posts with label Sorting. Show all posts
Showing posts with label Sorting. Show all posts

Sorting HashMap by Values including duplicate in Java

We have seen sorting HashMap based on custom objects by implementing Comparator and Comparable interfaces. Now lets see how to sort HashMap using values which has duplicate. Can be sorted with multiple ways like...

Selection sort

Selection sort is conceptually the most simplest sorting algorithm. This algorithm will first find the smallest element in the array and swap it with the element in the first position, then it will find the second smallest element and swap...

Selection sort in Java

Selection sort is a combination of searching (search for smaller element) and sorting (Swap with first element) and move on. During each pass unsorted element with the smallest value will be swapped to its...

Sorting duplicate elements in single array

There are lot of sorting algorithms like bubble sort, quick sort, insertion sort, rad-ix sort etc., But all these sorting algorithm gives array of elements in an ascending or descending order.  In point of...