Skip to content

Instantly share code, notes, and snippets.

@Dalamar42
Last active February 24, 2016 14:24
Show Gist options
  • Save Dalamar42/2d58735dda27f104ce8a to your computer and use it in GitHub Desktop.
Save Dalamar42/2d58735dda27f104ce8a to your computer and use it in GitHub Desktop.
Integer priority = 0;
def sortValue = null;
for (content in _source.content) {
// Get the priority of the source. Higher is better
Integer thisPriority = priorities.get(content.source);
// Get the value of the field we want to sort on
def thisValue = content[sortField];
// If a value exists and it has higher priority replace the chosen sort value
if (thisValue != null && thisPriority > priority) {
priority = thisPriority;
sortValue = thisValue;
}
}
return sortValue;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment