我有一个以表格形式呈现的用户列表。活跃用户应该排在非活跃用户之上。
我正在尝试使用 lodash 的 sortBy
函数进行排序,但并没有成功。
这是 userArray
的样子:
const userArray [
{
// I need to show users which have disabled = false first
// and then users with disabled = true
disabled: true, // <==========
email: "hgaither@cmregent.com",
firstName: "Harriet",
lastName: "Gaither",
role: "claimsHandlerSupervisor",
userId: "03VFpxtMWgY1jKDHDLcrWSw1qzx1",
},
{
disabled: false, // <===========
email: "hgaither@cmregent.com",
firstName: "Harriet",
lastName: "Gaither",
role: "claimsHandlerSupervisor",
userId: "03VFpxtMWgY1jKDHDLcrWSw1qzx1",
},
]
这里有一个使用users数组和sortBy loadsh函数的代码片段:
https://codepen.io/nikolatrajkovicq/pen/pGXdpM?editors=1112欢迎提出任何建议。