Closed stevenjoezhang closed 4 years ago
https://github.com/mziccard/node-timsort
There is a high performance tim-sort implementation that could be used as an alternative.
Another approach is
const posts = locals.posts.sort(`${config.index_generator.order_by} -sticky`);
However, the current implementation of warehouse does not support setting default values for sort (e.g. sticky = 0), thus the sorting will not take effect unless every post has a sticky
or order
attribute.
https://github.com/hexojs/warehouse/blob/c24cf938152ea0c3fd04a9bac0ca1db8e661bdb2/lib/schema.js#L60
Test cases / docs will be updated later.
Node.js 12+ uses stable sorting algorithms by default, thus
timsort
is only used for Node.js 10 compatibility. It should be replaced after Node.js 10 EOL. https://v8.dev/features/stable-sort