...
General Functions
transform
transform(<obj>,<sort options> |,<global options>)
Parameter | Datatype | Required |
---|---|---|
<obj> | hash/map or array | √ |
<sort options> | hash or array of hashes | √ |
<global options> | hash |
...
A note on datetime formats. The sorting algorithm should recognize ISO8601 and common internet and email formats. The format returned by Twitter is slightly different and requires a format string to allow the sort mechanism to parse correctly. The Twitter format string is demonstrated in examples below.
Providing a hash as the obj, will return an array of the hash keys sorted by the provided parameters (sort by reference)
Examples
Code Block | ||||
---|---|---|---|---|
| ||||
myHash = { "0001" : { "type": "donut", "name": "Cake", }, "0002" : { "type": "donut", "name": "Raised", }, "0003": { "type": "donut", "name": "Old Fashioned", }, "0004" : { "type": "muffin", "name": "Poppy seed", } }; sort_opt = { 'path' : ['name'] }; sorted_array = this2that:transform(myHash,sort_opt); // ["0001", "0003", "0004", "0002"] |
...