Comments (5)
三群的hodor这个 在算法上也可以,但是我的bbb在IE6-8下为一个VBS对象组成的对象数组,VBS对象不能动态添加新属性,因此不可用
var aaa = [1, 2, 3, 4, 5, 1];
var aas = aaa.slice(0);
var bbb = [{v: 2}, {v: 3}, {v: 1}, {v: 1}, {v: 5}, {v: 4}];
bbb.map(function(a) {
var i = aas.indexOf(a.v);
aas[i] = null;
a.sv = i;
return a
});
bbb.sort(function(a, b) {
return a.sv - b.sv;
});
bbb.map(function(a) {
delete a.sv;
});
console.log(bbb);
from avalon.
想知道这东西有什么用,可以看这里 https://github.com/RubyLouvre/avalon/blob/0851/avalon.js#L2593
from avalon.
鬼懿IT 群的蚂蚁 zzbo给出的版本
var aaa = [1, 2, 3, 4, 5, 1];
var bbb = [{v: 2}, {v: 3}, {v: 1}, {v:1},{v: 5}, {v: 4}];
var aaaTmp = aaa.slice();
var bbbTmp = [];
var index;
for (var i = 0, len = aaaTmp.length; i < len; i++) {
index = aaaTmp.indexOf(bbb[i].v);
bbbTmp[index] = bbb[i];
aaaTmp[index] = null;
}
bbbTmp;
from avalon.
http://jsfiddle.net/z3341789/mWc93/
from avalon.
http://jsfiddle.net/z3341789/mWc93/
from avalon.
Related Issues (20)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from avalon.