+2

Can any one explain me this theory of sorting an array

let values = [144,248,169,276,340,96,47,24,68,194]; console.log(values) //console.log(values.sort()) values.sort((a,b)=>console.log("a=",a,"b=",b,"a-b=",a-b)) console.log(values)

12/31/2019 5:15:08 PM

Neo 👑

2 Answers

New Answer

+1

I think javascript engine might assuming a-value as b-value and b-value as a-value(like (a, b) => a=248,b=144) instead actual assumption might be (like (a, b) => a=144,b=248)....plz help me i gonna mad by this algorithm or javascript engine...

+1

Oops! I got a answer where it's javascript engine in sololearn app which assuming a-value as b-value and b-value as a-value