Keysort
Sorts an Array of Objects with SQL ORDER BY clause syntax
Install / Use
/learn @avoidwork/KeysortREADME
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.
Related Skills
feishu-drive
346.8k|
things-mac
346.8kManage Things 3 via the `things` CLI on macOS (add/update projects+todos via URL scheme; read/search/list from the local Things database)
clawhub
346.8kUse the ClawHub CLI to search, install, update, and publish agent skills from clawhub.com
codebase-memory-mcp
1.2kHigh-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph — average repo in milliseconds. 66 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.
