Example perf on smaller arrays

Benchmark created on


Setup

const data = [...Array(100).fill().map((el, i) => ({name: `item ${i}`, isHighlighted: undefined}))]

data[4].isHighlighted = true
data[23].isHighlighted = true
data[58].isHighlighted = true

Test runner

Ready to run.

Testing in
TestOps/sec
Sort
data.sort((a, b) => {
      if (a.isHighlighted == b.isHighlighted) return 0
      return a.isHighlighted ? -1 : 1
    })
ready
Concat
data.filter((el) => el.isHighlighted)
    .concat(
      data
        .filter((el) => !el.isHighlighted),
    )
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.