Function listSort

根据字段排序数据列表,支持多字段排序

const list = [
{ name: 'John', age: 25 },
{ name: 'Jane', age: 30 },
]
const sortedList = listSort(list, ['name', 'age'], 'desc')
const sortedList2 = listSort(list, ['name', 'age'], ['desc', 'asc'])
  • Parameters

    • list: Record<string, any>[]

      数据列表

    • fields: string[]

      排序字段列表

    • order: SortOrder | SortOrder[] = 'asc'

      排序类型,默认为'asc'

    Returns Record<string, any>[]