You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.hbs
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,8 @@ Sort an array of primitives, for example strings.
23
23
[ 'afternoon', 'evening', 'morning', 'twilight' ]
24
24
```
25
25
26
+
### Custom sort order
27
+
26
28
The default sort order is `asc`. You can also specify `desc` or the name of a property from the `customOrders` object. For example, sort parts of the day by the order in which they occur.
27
29
28
30
```js
@@ -35,6 +37,8 @@ The default sort order is `asc`. You can also specify `desc` or the name of a pr
35
37
[ 'morning', 'afternoon', 'evening', 'twilight' ]
36
38
```
37
39
40
+
### Sort by computed field
41
+
38
42
Sort by a computed field, i.e. a computed value that doesn't exist in the input dataset. Define your computed fields in the `options.computed` object, each value being a function which takes an array member as input and returns the primitive value to be sorted by. In this example we sort by `total` (the name of the computed field supplied in `options.computed`).
39
43
40
44
```js
@@ -58,6 +62,8 @@ Sort by a computed field, i.e. a computed value that doesn't exist in the input
58
62
]
59
63
```
60
64
65
+
### Sort by deep object values
66
+
61
67
You can use computed fields to sort by values deep in an object structure.
62
68
63
69
```js
@@ -80,6 +86,8 @@ You can use computed fields to sort by values deep in an object structure.
80
86
]
81
87
```
82
88
89
+
### Sort by multiple fields
90
+
83
91
Sort by multiple columns using multiple custom orders.
84
92
85
93
```js
@@ -118,6 +126,8 @@ Sort by multiple columns using multiple custom orders.
118
126
119
127
Please visit [the sort-array wiki](https://github.com/75lb/sort-array/wiki) for more examples.
Copy file name to clipboardExpand all lines: README.md
+12-2Lines changed: 12 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,8 @@ Sort an array of primitives, for example strings.
23
23
[ 'afternoon', 'evening', 'morning', 'twilight' ]
24
24
```
25
25
26
+
### Custom sort order
27
+
26
28
The default sort order is `asc`. You can also specify `desc` or the name of a property from the `customOrders` object. For example, sort parts of the day by the order in which they occur.
27
29
28
30
```js
@@ -35,6 +37,8 @@ The default sort order is `asc`. You can also specify `desc` or the name of a pr
35
37
[ 'morning', 'afternoon', 'evening', 'twilight' ]
36
38
```
37
39
40
+
### Sort by computed field
41
+
38
42
Sort by a computed field, i.e. a computed value that doesn't exist in the input dataset. Define your computed fields in the `options.computed` object, each value being a function which takes an array member as input and returns the primitive value to be sorted by. In this example we sort by `total` (the name of the computed field supplied in `options.computed`).
39
43
40
44
```js
@@ -58,6 +62,8 @@ Sort by a computed field, i.e. a computed value that doesn't exist in the input
58
62
]
59
63
```
60
64
65
+
### Sort by deep object values
66
+
61
67
You can use computed fields to sort by values deep in an object structure.
62
68
63
69
```js
@@ -80,6 +86,8 @@ You can use computed fields to sort by values deep in an object structure.
80
86
]
81
87
```
82
88
89
+
### Sort by multiple fields
90
+
83
91
Sort by multiple columns using multiple custom orders.
84
92
85
93
```js
@@ -118,9 +126,11 @@ Sort by multiple columns using multiple custom orders.
118
126
119
127
Please visit [the sort-array wiki](https://github.com/75lb/sort-array/wiki) for more examples.
120
128
129
+
## API Reference
130
+
121
131
<aname="module_sort-array"></a>
122
132
123
-
## sort-array
133
+
###sort-array
124
134
Isomorphic, load-anywhere function to sort an array by scalar, deep or computed values in any standard or custom order.
0 commit comments