mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-06 02:03:24 +08:00
Improved error message
This commit is contained in:
@@ -11,6 +11,23 @@ var sortByOperatorScenarios = []expressionScenario{
|
||||
"D0, P[], (!!seq)::[{a: apple}, {a: banana}, {a: cat}]\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "Sort array in place",
|
||||
document: "cool: [{a: banana},{a: cat},{a: apple}]",
|
||||
expression: `.cool |= sort_by(.a)`,
|
||||
expected: []string{
|
||||
"D0, P[], (doc)::cool: [{a: apple}, {a: banana}, {a: cat}]\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "Sort array of objects by key",
|
||||
subdescription: "Note that you can give sort_by complex expressions, not just paths",
|
||||
document: "cool: [{b: banana},{a: banana},{c: banana}]",
|
||||
expression: `.cool |= sort_by(keys | .[0])`,
|
||||
expected: []string{
|
||||
"D0, P[], (doc)::cool: [{a: banana}, {b: banana}, {c: banana}]\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "Sort is stable",
|
||||
subdescription: "Note the order of the elements in unchanged when equal in sorting.",
|
||||
|
||||
Reference in New Issue
Block a user