|
Last change
on this file since e4c61dd was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago |
|
Prototype 1.1
|
-
Property mode
set to
100644
|
|
File size:
429 bytes
|
| Line | |
|---|
| 1 | import ascending from "./ascending.js";
|
|---|
| 2 | import group, {rollup} from "./group.js";
|
|---|
| 3 | import sort from "./sort.js";
|
|---|
| 4 |
|
|---|
| 5 | export default function groupSort(values, reduce, key) {
|
|---|
| 6 | return (reduce.length !== 2
|
|---|
| 7 | ? sort(rollup(values, reduce, key), (([ak, av], [bk, bv]) => ascending(av, bv) || ascending(ak, bk)))
|
|---|
| 8 | : sort(group(values, key), (([ak, av], [bk, bv]) => reduce(av, bv) || ascending(ak, bk))))
|
|---|
| 9 | .map(([key]) => key);
|
|---|
| 10 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.