Sorting Array with JavaScript reduce function

in #sthink6 years ago

Often I study some JavaScript interview questions, suddenly I saw a question about usage of reduce function for sorting an Array, I read about in MDN and the usage of it in some medium articles, But sorting an Array is so Innovative:

const arr = [91,4,6,24,8,7,59,3,13,0,11,98,54,23,52,87,4];

I thought a lot, but I've no idea about how answer this question, how must be the reduce call back function? what is the initialValue of reduce function? and what are the accumulator and currentValue of call back function of reduce?

And at the end, Does this way have some benefits than other sorting algorithms? Or Is it useful to improve other algorithms?

Coin Marketplace

STEEM 0.18
TRX 0.13
JST 0.028
BTC 57292.40
ETH 3073.43
USDT 1.00
SBD 2.32