Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sort results in search & info #7

Closed
job opened this issue Sep 4, 2015 · 2 comments
Closed

sort results in search & info #7

job opened this issue Sep 4, 2015 · 2 comments

Comments

@job
Copy link

job commented Sep 4, 2015

is it possible to (by default) sort the results in the search window or the info window when you click a node? For some PMs it might make sense to sort the search results on name, or on in-degree, right now it is all random it seems. I'd prefer by default an alpabetic/numeric sort on the name of the node

@job
Copy link
Author

job commented Sep 5, 2015

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 ;-)

@job job closed this as completed Sep 5, 2015
@anvaka
Copy link
Owner

anvaka commented Sep 8, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants