Skip to content

Instantly share code, notes, and snippets.

@iaindooley
Created March 24, 2020 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iaindooley/d3741a615c172551a5cfb6a14c71a31f to your computer and use it in GitHub Desktop.
Save iaindooley/d3741a615c172551a5cfb6a14c71a31f to your computer and use it in GitHub Desktop.
Sort lists by labels and description
function sortListByLabel(notification)
{
var moved = new Notification(notification).movedCard();
moved.currentList().sort(function(card1,card2)
{
var ret = 0;
try
{
if(card1.labels().first().name().toLowerCase() > card2.labels().first().name().toLowerCase())
ret = 1;
else if(card1.labels().first().name().toLowerCase() < card2.labels().first().name().toLowerCase())
ret = -1;
}
catch(e)
{
Notification.expectException(InvalidDataException,e);
}
return ret;
});
}
function sortListByDescription(notification)
{
var moved = new Notification(notification).movedCard();
moved.currentList().sort(function(card1,card2)
{
var ret = 0;
if(card1.description().toLowerCase() > card2.description().toLowerCase())
ret = 1;
else if(card1.description().toLowerCase() < card2.description().toLowerCase())
ret = -1;
return ret;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment