- Notifications
You must be signed in to change notification settings - Fork20.1k
Description
What would you like to share?
This issue proposes a refactoring to standardize the comparison logic across various sorting algorithms in thesorts
directory.
Currently, some sorting algorithm implementations directly useComparable.compareTo()
for element comparisons (e.g.,array[i].compareTo(array[j]) > 0
), while others utilize the utility methods provided bySortUtils
(e.g.,SortUtils.greater(array[i], array[j])
).
The goal of this refactoring is to replace directcompareTo()
calls with the correspondingSortUtils.less()
,SortUtils.greater()
, orSortUtils.greaterOrEqual()
methods where applicable.
Additional information
I have identified the following files that currently use directcompareTo()
calls and can be refactored:
AdaptiveMergeSort.java
BinaryInsertionSort.java
BitonicSort.java
BucketSort.java
(partial, wherecompareTo
is used for boolean comparison)CircleSort.java
DutchNationalFlagSort.java
ExchangeSort.java
FlashSort.java
(partial, wherecompareTo
is used for boolean comparison)IntrospectiveSort.java
OddEvenSort.java
SelectionSort.java
SelectionSortRecursive.java
StalinSort.java
StrandSort.java
WiggleSort.java
(partial, wherecompareTo
is used for boolean comparison)
(Note: Files likeCycleSort.java
,PatienceSort.java
,SpreadSort.java
that usecompareTo()
for equality checks or value calculations will not be modified, asSortUtils
does not provide direct equivalents for these specific use cases.)
I am willing to create a Pull Request to implement this refactoring.