Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sort checklist items
var card = new Card({link: "https://trello.com/c/VSZc0gQi"});//click "Share" on the card to get the link
var sorted = card.checklist("My Checklist").items().asArray();
comparator = function(item1,item2)
{
var ret = 0;
if(item1.name().toLowerCase() > item2.name().toLowerCase())
ret = 1;
else if(item1.name().toLowerCase() < item2.name().toLowerCase())
ret = -1;
return ret;
};
sorted.sort(comparator);
new IterableCollection(sorted).each(function(item,key)
{
item.setPosition(parseInt(key)+1);
}.bind(this));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment