Git Product home page Git Product logo

Comments (5)

RubyLouvre avatar RubyLouvre commented on August 15, 2024

三群的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.

RubyLouvre avatar RubyLouvre commented on August 15, 2024

想知道这东西有什么用,可以看这里 https://github.com/RubyLouvre/avalon/blob/0851/avalon.js#L2593

from avalon.

RubyLouvre avatar RubyLouvre commented on August 15, 2024

鬼懿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.

RubyLouvre avatar RubyLouvre commented on August 15, 2024

http://jsfiddle.net/z3341789/mWc93/

from avalon.

RubyLouvre avatar RubyLouvre commented on August 15, 2024

http://jsfiddle.net/z3341789/mWc93/

from avalon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.