Skip to content

Instantly share code, notes, and snippets.

@thedevsaddam
Created July 10, 2018 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thedevsaddam/19d9a3015838638aed77ab423003bac1 to your computer and use it in GitHub Desktop.
Save thedevsaddam/19d9a3015838638aed77ab423003bac1 to your computer and use it in GitHub Desktop.
How to use SortBy method
package main
import (
"fmt"
"github.com/thedevsaddam/gojsonq"
)
func main() {
jq := gojsonq.New().File("./sample-data.json")
res := jq.From("vendor.items").SortBy("price").Get()
fmt.Println(res)
// output: [map[id:<nil> name:HP core i3 SSD price:850] map[id:4 name:Fujitsu price:850] map[id:5 name:HP core i5 price:850 key:2300] map[id:6 name:HP core i7 price:950] map[id:3 name:Sony VAIO price:1200] map[id:1 name:MacBook Pro 13 inch retina price:1350] map[id:2 name:MacBook Pro 15 inch retina price:1700]]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment