javascript - Sorting Array list of equal length Arrays based on index -
i trying sort large array list of arrays using below code
function _stind(arr, ind){ return arr.sort(function(a, b) { var _1 = a[ind]; var _2 = b[ind]; return (_1 < _2) ? -1 : (_1 > _2) ? 1 : 0; }); }
please @ bin more info http://jsbin.com/uqepofa/3/edit
the code working fine , able sort also. problem is taking if trying sort more 1 million list of arrays based on 1 index.
please suggest me improve code
i suggest 2 specific things:
take in consideration data-set need sort, helps in sorting faster. (as mentioned in comment, if limited range counting sort)
start using multi-threading (actually called worker threads). yes javascript doest support now. merge sort , start showing results partially. more details on how use multi-threading, refer worker threads. 1 tutorial can think of http://ejohn.org/blog/web-workers/
Comments
Post a Comment