Skip to content

Instantly share code, notes, and snippets.

@meandavejustice
Created December 4, 2013 19:40
Show Gist options
  • Save meandavejustice/7794166 to your computer and use it in GitHub Desktop.
Save meandavejustice/7794166 to your computer and use it in GitHub Desktop.
// currently sorting my collection with this comparator.
// It sets up a relationship so that a Parent Item should be before its sub-items(you can think of these as sub tasks)
// 'parent' attribute is just the 'pk' of the parent item.
// This is working fantastically but I need to sort at a higher level above this descending from an attribute called
// 'created_at'.
// the `else` refers to items that are either parents, or items that have no relationship to any others.
comparator: function(item) {
if (item.isSubItem()) {
return [item.get('parent'), item.get('pk')];
} else {
return [item.get('pk'), 0];
}
},
// so it really should look something like this when complete.
// [itemCreatedTodayWithNoParents, parentItemCreatedYesterday, subItemOfpreviousParentCreatedWhenever, itemCreatedLastWeek]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment