3.0.1 • Published 7 months ago

keysort v3.0.1

Weekly downloads
18
License
BSD-3-Clause
Repository
github
Last release
7 months ago

keysort

Sorts an Array of Objects with SQL ORDER BY clause syntax.

Using the module

import {keysort} from "keysort";
const arr = [{abc: 123124, xyz: 5}, {abc: 123124, xyz: 6}, {abc: 2, xyz: 5}];

keysort(arr, "abc, xyz"); // [{abc: 2, xyz: 5}, {abc: 123124, xyz: 5}, {abc: 123124, xyz: 6}];
keysort(arr, "abc, xyz desc"); // [{abc: 2, xyz: 5}, {abc: 123124, xyz: 6}, {abc: 123124, xyz: 5}];

Testing

keysort has 100% code coverage with its tests.

-------------|---------|----------|---------|---------|-------------------
File         | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-------------|---------|----------|---------|---------|-------------------
All files    |     100 |       80 |     100 |     100 |                  
 keysort.cjs |     100 |       80 |     100 |     100 | 25               
-------------|---------|----------|---------|---------|-------------------

API

keysort(arr = [], order = "", toSorted = false)

Sorts an Array of Objects with SQL ORDER BY clause syntax. If toSorted is true, a new sorted Array is returned.

License

Copyright (c) 2023 Jason Mulligan
Licensed under the BSD-3 license.

3.0.1

7 months ago

3.0.0

7 months ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.2.0

10 years ago

0.1.1

11 years ago

0.1.0

11 years ago