基于多个字段在javascript中对数组数组进行排序

时间:2015-07-18 06:30:58

标签: javascript arrays sorting multiple-columns

1) create two sub array from your main array  
`positive {5,7,2,9,11,19}` and `negative {-10,-2,-5}`   
2) remove element from positive array which does not satisfy condition
   condition -> value should be construct from negative arrays element  
   or sum of  its elements  
   ie.   
       5 = -5 //so keep it //don't consider the sign  
       7 = (-5 + -2 ) // keep  
       2 = -2 // keep
       9 // cannot be construct using -10,-2,-5  
       same for all 11 and 19
3) remove element form negative array which does not satisfy condition
      condition -> value should be construct from positive arrays element  
       or sum of  its elements   
  i.e. -10 // cannot be construct so discard  
       -2 = 2 // keep  
       -5 = 5 // keep 

以上是我的代码:

我想基于两个字段State和City按字母顺序对此数组进行排序。 以上示例的排序数组应为:     结果= [['洛杉矶','洛杉矶',84],['奥斯汀','TX',84],['休斯顿','TX',84];

请建议我使用JavaScript解决方案

0 个答案:

没有答案