Sorting Array with JavaScript reduce function

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?

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center