0
私はいくつかのlodash sortBy関数をチェーンしようとしていますが、最後のsortByでは条件付きにしたいと思います。lodashの作り方sortByは値が等しい場合ソートしない
const events = _(arr).chain().sortBy((e) => {
return e.event.json.QUERY.type
}).sortBy((e) => {
if (e.event.json.QUERY.type === 'ad') {
return e.event.json.QUERY.metadata.ad.assetid;
} else {
return e.event.json.QUERY.metadata.content.assetid;
}
}).sortBy((e) => {
return e.event.json.QUERY.utc; // this is where I want a conditional but I don't know if that's possible with lodash
}).value()
ありがとうございます。私は以前のアレイでコンソールロギングをしていたに違いないが、新しいアレイが実際に私が望んでいたことを認識していなかった。ありがとう! – Steve
[[回答を受け入れたとマークする](http://stackoverflow.com/help/someone-answers)を忘れないでください。 – trincot