When querying JSON documents with the find command, you can use the
--orderby option to order the data. You can specify either an ascending or
descending sort using the keywords, ASC and DESC.
find <table path> --orderby <field path>:<sortorder>The
keywords ASC and DESC are case insensitive. Ascending is
the default sort order.
The following sample JSON document is used in examples in this section:
{
"_id": "id1",
"a": {
"b": [{"boolean":false}, {"decimal": 123.456}],
"c":{
"d":10,
"e":"Hello"
}
},
"m":"MapR wins"
}
The following syntax and example are a simple sort on a single field path in the default ascending sort order:
// Syntax
find <table path> --orderby <field path>
// Example
find /tbl --orderby a.c.d
The following syntax and example are a sort with a specified ordering on a single field path:
// Syntax
find <table path> --orderby <field path>:<sort order>
// Example
find /tbl --orderby a.c.d:desc
The following syntax and example specify a sort ordering on each field path:
// Syntax
find <table path> --orderby <field path>:<sort order>,<field path>:<sort order>
// Example
find /tbl --orderby a.c.d:asc,a.c.e:desc
The following syntax and example specify a sort ordering on one field path and use the default sort order (ascending) on another field path.
// Syntax
find <table path> --orderby <field path>:<sort order>,<field path>
// Example
find /tbl --orderby a.c.d:DESC,a.c.e