Closed job closed 9 years ago
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 ;-)
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.
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