const a = [ { k: 1, me: false, prim: false }, { k: 2, me: false, prim: false }, { k: 3, me: false, prim: false }, { k: 4, me: false, prim: false }, { k: 5, me: true, prim: true }, { k: 6, me: false, prim: false } ] a .sort((x, y) => (x.prim === y.prim) ? 0 : x.prim ? -1 : 1) .sort((x, y) => (x.me === y.me) ? 0 : x.me ? -1 : 1) console.log(a)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter