File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change 44package json_test
55
66import (
7- "sort "
7+ "slices "
88 "testing"
99
1010 "github.com/google/go-cmp/cmp"
@@ -80,11 +80,20 @@ func TestCreatePatchFromStrings(t *testing.T) {
8080 sortTransformer := cmp .Transformer ("SortPatchOps" , func (ops []mattbairdjsonpatch.JsonPatchOperation ) []mattbairdjsonpatch.JsonPatchOperation {
8181 sorted := make ([]mattbairdjsonpatch.JsonPatchOperation , len (ops ))
8282 copy (sorted , ops )
83- sort .Slice (sorted , func (i , j int ) bool {
84- if sorted [i ].Operation != sorted [j ].Operation {
85- return sorted [i ].Operation < sorted [j ].Operation
83+ slices .SortFunc (sorted , func (a , b mattbairdjsonpatch.JsonPatchOperation ) int {
84+ if a .Operation != b .Operation {
85+ if a .Operation < b .Operation {
86+ return - 1
87+ }
88+ return 1
8689 }
87- return sorted [i ].Path < sorted [j ].Path
90+ if a .Path < b .Path {
91+ return - 1
92+ }
93+ if a .Path > b .Path {
94+ return 1
95+ }
96+ return 0
8897 })
8998 return sorted
9099 })
You can’t perform that action at this time.
0 commit comments