Sorting with Mongo
Change .sort({ featured: 1 })
to .sort({ featured: -1 })
. You want those with featured
value of true
to come before those with false false
.
It looks like default sorting by boolean fields goes from false to true (maybe because of 0 and 1 numerical values, and default ascending order). To demonstrate this, open the Chrome Dev Tools console, enter [true, false, false, true].sort()
, and the result is [false, false, true, true]
.