| 1 |
Authorscip-debian debian golang-github-thedevsaddam-gojsonq 2.5.2-4 golang-github-thedevsaddam-gojsonq/patches/`01-Stable_sort.patch`#Author.: Martina Ferrari <[email protected]scip-debian . . . identity/`[email protected]`.> |
| 2 |
Datescip-debian debian golang-github-thedevsaddam-gojsonq 2.5.2-4 golang-github-thedevsaddam-gojsonq/patches/`01-Stable_sort.patch`#Date.: Tue, 23 Aug 2022 12:55:20 +0000 |
| 3 |
Descriptionscip-debian debian golang-github-thedevsaddam-gojsonq 2.5.2-4 golang-github-thedevsaddam-gojsonq/patches/`01-Stable_sort.patch`#Description.: Use stable sorting for maps and adjust test. |
| 4 |
Forwardedscip-debian debian golang-github-thedevsaddam-gojsonq 2.5.2-4 golang-github-thedevsaddam-gojsonq/patches/`01-Stable_sort.patch`#Forwarded.: No |
| 5 |
--- a/helper.goscip-debian debian golang-github-thedevsaddam-gojsonq 2.5.2-4 golang-github-thedevsaddam-gojsonq/upstream/`helper.go`: |
| 6 |
+++ b/helper.goscip-debian debian golang-github-thedevsaddam-gojsonq 2.5.2-4 golang-github-thedevsaddam-gojsonq/upstream/`helper.go`: |
| 7 |
@@ -113,7 +113,7 @@ |
| 8 |
// Sort sorts the slice of maps |
| 9 |
func (s *sortMap) Sort(data interface{}) { |
| 10 |
s.data = data |
| 11 |
|
| 12 |
+ sort.Stable(s) |
| 13 |
} |
| 14 |
|
| 15 |
// Len satisfies the sort.Interface |
| 16 |
--- a/jsonq_test.goscip-debian debian golang-github-thedevsaddam-gojsonq 2.5.2-4 golang-github-thedevsaddam-gojsonq/upstream/`jsonq_test.go`: |
| 17 |
+++ b/jsonq_test.goscip-debian debian golang-github-thedevsaddam-gojsonq 2.5.2-4 golang-github-thedevsaddam-gojsonq/upstream/`jsonq_test.go`: |
| 18 |
@@ -661,7 +661,7 @@ |
| 19 |
jq := New().FromString(jsonStr). |
| 20 |
From("vendor.items"). |
| 21 |
SortBy("price") |
| 22 |
|
| 23 |
+ expected := `[{"id":4,"name":"Fujitsu","price":850},{"id":5,"key":2300,"name":"HP core i5","price":850},{"id":null,"name":"HP core i3 SSD","price":850},{"id":6,"name":"HP core i7","price":950},{"id":3,"name":"Sony VAIO","price":1200},{"id":1,"name":"MacBook Pro 13 inch retina","price":1350},{"id":2,"name":"MacBook Pro 15 inch retina","price":1700}]` |
| 24 |
out := jq.Get() |
| 25 |
assertJSON(t, out, expected, "sorting array of object by its key (price-float64) in ascending desc") |
| 26 |
} |