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:

  1. take in consideration data-set need sort, helps in sorting faster. (as mentioned in comment, if limited range counting sort)

  2. 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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -