Last active
February 24, 2016 14:24
-
-
Save Dalamar42/2d58735dda27f104ce8a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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