I have a custom scripted field to count the number of issue links and dump the value into a custom field for the purposes of reporting. The goal is to be able to sort issues descending by the amount of linked issues.
This is my field code:
import com.atlassian.jira.component.ComponentAccessor
a = ComponentAccessor.getIssueLinkManager().getLinkCollection(issue, issue.reporter).getAllIssues().size()
a.toString()
Everything works as expected except when I sort. I have one issue with 34 links, and it comes WAY down in the list after issues that only have 1 or 2 links.
What I can observe happening, is that Jira is sorting by the first digit only. For example, sorting by this field DESC yields the following pattern:
14
10
1
1
22
2
2
34
3
31
as an example.