MCPcopy Create free account
hub / github.com/SmartThingsCommunity/smartthings-cli / sort

Function sort

src/lib/command/output.ts:10–19  ·  view source on GitHub ↗
(list: L[], keyName?: Extract<keyof L, string>)

Source from the content-addressed store, hash-verified

8
9
10export const sort = <L extends object>(list: L[], keyName?: Extract<keyof L, string>): L[] => {
11 if (!keyName) {
12 return list
13 }
14 return list.sort((a, b) => {
15 const av = (a[keyName] as unknown as string).toLowerCase()
16 const bv = (b[keyName] as unknown as string).toLowerCase()
17 return av === bv ? 0 : av < bv ? -1 : 1
18 })
19}
20
21export type CalculateOutputFormatFlags = {
22 output?: string

Callers 4

outputListFunction · 0.85
stringTranslateToIdFunction · 0.85
translateToIdFunction · 0.85
output.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected