Merge pull request #1825 from C-Otto/sort-containers

Sort containers
This commit is contained in:
Matt Rogers 2015-08-07 20:35:54 -04:00
commit 50421fc19b
8 changed files with 63 additions and 13 deletions

View file

@ -184,5 +184,21 @@ var TracksPages = {
/* fade flashes and alerts in automatically */
$(".alert").fadeOut(8000);
}, sort_container: function(container) {
function comparator(a, b) {
var contentA = $(a).attr('data-sort') || '';
var contentB = $(b).attr('data-sort') || '';
if (contentA > contentB) {
return 1;
}
if (contentB > contentA) {
return -1;
}
return 0;
}
var unsortedActions = container.children();
var sortedChildren = unsortedActions.sort(comparator);
container.append(sortedChildren);
}
};