alphabetical

变量

按 `getter` 返回的字符串对数组做字母序排序,第三个参数可选 `'asc' | 'desc'`

签名

const alphabetical: <T>(array: readonly T[], getter: (item: T) => string, dir?: "asc" | "desc") => T[]

示例

alphabetical([{ name: 'Zeus' }, { name: 'Loki' }], (item) => item.name)
// [{ name: 'Loki' }, { name: 'Zeus' }]

源码

node_modules/.pnpm/radash@12.1.1/node_modules/radash/dist/index.d.ts:58