mirror of
https://github.com/duke-git/lancet.git
synced 2026-11-16 05:12:11 +08:00
fix(package): [algorithm] keep duplicate CountSort entries (#387)
This commit is contained in:
1 parent
3811d3db8e
commit
cb45ef2d36
2 files changed
+5
-1
No files matched your search
+2
-1
@@ -188,7 +188,8 @@ func CountSort[T any](slice []T, comparator constraints.Comparator) []T {
|
||||
count := 0
|
||||
for j := 0; j < size; j++ {
|
||||
//slice[i] > slice[j]
|
||||
if comparator.Compare(slice[i], slice[j]) == 1 {
|
||||
order := comparator.Compare(slice[i], slice[j])
|
||||
if order == 1 || (order == 0 && j < i) {
|
||||
count++
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user