Skip to content

Commit

Permalink
fix sort by name bug (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancandevloper authored and weilaaa committed Jul 4, 2023
1 parent 4745812 commit 3002803
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/utils/filter/sort_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ func SortHandler(items []unstructured.Unstructured, param *SortParam) ([]unstruc
if err != nil {
return false
}
if param.sortFunc == "asc" {
return strings.Compare(before, after) < 0
if param.sortOrder == "asc" {
return strings.Compare(before, after) != 1
} else {
return strings.Compare(before, after) > 0
return strings.Compare(before, after) == 1
}
case "time":
before, after, err := getStringFunc(items, i, j)
Expand Down Expand Up @@ -109,9 +109,9 @@ func SortHandler(items []unstructured.Unstructured, param *SortParam) ([]unstruc
return false
}
if param.sortOrder == "asc" {
return strings.Compare(before, after) < 0
return strings.Compare(before, after) != 1
} else {
return strings.Compare(before, after) > 0
return strings.Compare(before, after) == 1
}
}
})
Expand Down

0 comments on commit 3002803

Please sign in to comment.