GithubHelp home page GithubHelp logo

sort results in search & info about pm HOT 2 CLOSED

anvaka avatar anvaka commented on September 25, 2024
sort results in search & info

from pm.

Comments (2)

job avatar job commented on September 25, 2024

I added sorting for my instance, in src/galaxy/windows/windowView.jsx I added this function:

// sorting function for sorting by value of object in object
function sort_object_of_objects(data, attr) {
    var arr = [];
    for (var prop in data) {
        if (data.hasOwnProperty(prop)) {
            var obj = {};
            obj[prop] = data[prop];
            obj.tempSortName = data[prop][attr].toLowerCase();
            arr.push(obj);
        }
    }

    arr.sort(function(a, b) {
        var at = a.tempSortName,
            bt = b.tempSortName;
        at = at.split(' ', 1)[0].slice(2);
        bt = bt.split(' ', 1)[0].slice(2);
        return at - bt;
    });

    var result = [];
    for (var i=0, l=arr.length; i<l; i++) {
        var obj = arr[i];
        delete obj.tempSortName;
        for (var prop in obj) {
            if (obj.hasOwnProperty(prop)) {
                var id = prop;
            }
        }
        var item = obj[id];
        result.push(item);
    }
    return result;
}

And later on in function windowView(x) call like this:

var items = sort_object_of_objects(windowViewModel.list, 'name');

Not generic, but works for me ;-)

from pm.

anvaka avatar anvaka commented on September 25, 2024

I see a lot of value in this, but it comes at cost of O(n * lg n) on each keystroke.

I'll add sorting as well, and will let users opt in for it. E.g. window title could provide a combobox which allows users to select by name, by in-degree or out-degree.

from pm.

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.