Method to sort the array using CombSort @param arr the array to be sorted @param the type of elements in the array @return the sorted array
(T[] arr)
| 37 | * @return the sorted array |
| 38 | */ |
| 39 | @Override |
| 40 | public <T extends Comparable<T>> T[] sort(T[] arr) { |
| 41 | int gap = arr.length; |
| 42 | boolean swapped = true; |
| 43 | |
| 44 | while (gap != 1 || swapped) { |
| 45 | gap = getNextGap(gap); |
| 46 | swapped = performSwaps(arr, gap); |
| 47 | } |
| 48 | |
| 49 | return arr; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Method to perform the swapping of elements in the array based on the current gap |
nothing calls this directly
no test coverage detected