我有一组对象,我想首先按日期排序,即 desc 中的“create_date_format”,如果领带则按风险字母顺序排序,即 asc
我尝试了 lodash.orderBy(risk_list, ['create_date_format', 'risk'], ['desc']) 但由于日期是字符串格式,它按日期字符串中的数字排序,因此例如 2020 年 1 月 28 日出现在 2020 年 8 月 1 日之前28 高于 01。
let arr = [{
avoided: 0,
avoided_note: null,
create_date_format: "28 Sep 2020",
id: 209,
notes: "Nothing is happening",
risk: "very high risk",
severity: 3,
severity_name: "High",
type: 1,
type_name: "Internal"
}, {
avoided: 0,
avoided_note: null,
create_date_format: "23 Sep 2020",
id: 206,
notes: null,
risk: "Risk 12",
severity: 3,
severity_name: "High",
type: 2,
type_name: "External"
}, {
avoided: 0,
avoided_note: null,
create_date_format: "22 Sep 2020",
id: 202,
notes: "test note",
risk: "test risk",
severity: 3,
severity_name: "High",
type: 2,
type_name: "External"
}, {
avoided: 0,
avoided_note: null,
create_date_format: "23 Sep 2020",
id: 206,
notes: null,
risk: "abc Risk 12",
severity: 3,
severity_name: "High",
type: 2,
type_name: "External"
}]
我想先按日期排序,即 desc 中的“create_date_format”,如果是,则在 asc 中按字母顺序排列“风险”
DIEA
慕雪6442864
相关分类