i have data array like this
data = [1,2,3,4,5,6,7,8,9];
i want to giving result like this, example 1 + 3 = 4, 4 + 3 = 7,ect
data = [1,4,7,2,5,8,3,6,9];
i’m using data.sort(function(x,y) { return x % 3}); but nothing happen.
or any another suggestion ?
this is my jsfiddle http://jsfiddle.net/viyancs/Yt78J/3/
You need to return either
0,-1or+1indicating the desired order of the two items passed to the sorting function.