Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Can Project Versions be sorted alphabetically?

In the Project Versions list, when adding a new version it's inserted at the top of the list.  It seems the only way to reorder the list is by drag/drop.  This ability exists for sorting customer field options, but not in the Project Versions screen. 


Is there a built in method (preferable) or an add-on (acceptable) that can sort the Project Versions list alphabetically?  Currently running 6.3.12

2 answers

1 accepted

1 vote
Answer accepted

I've thrown this together; a JIRA admin can run it using the Script Console under "Add-Ons":

import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.project.version.VersionManager;
import com.atlassian.jira.project.version.Version;
import com.atlassian.jira.project.ProjectManager;
import com.atlassian.jira.project.Project;
VersionManager versionManager = ComponentManager.getInstance().getVersionManager();
ProjectManager projectManager = ComponentManager.getInstance().getProjectManager();

Project project = projectManager.getProjectByCurrentKey("MYPROJECT");
List<Version> versions = versionManager.getVersions(project);

if (versions != null && versions.size() > 0) {
    Collections.sort(versions, new Comparator<Version>(){
      public int compare(Version obj1, Version obj2) {
        if (obj1 == null) {
            return -1;
        if (obj2 == null) {
            return 1;
        if (obj1.getName() == obj2.getName()) {
            return 0;
        return obj2.getName().compareTo(obj1.getName());
    for(int i=1;i<versions.size(); i++) {
return versions;

I had to use "getVersion()" in the call to "moveVersionAfter()", because, otherwise, the signature of the Version object in the List didn't always match the underlying collection due to having been re-sequenced by a previous call, and so the method failed.  Additionally, this is using the basic String.compareTo() comparison, which means "10" comes after "2"; with your version padding, that may not be an issue, but it's something I'll have to work on for my own in a bit.

If you uncomment "return versions" after the sort method, you can see what the sorted list will look like before running it with side effects enabled.  And if you want them sorted in ASC order instead of DESC order, switch the ob2/ob1 in the compareTo call.  And, of course, replace MYPROJECT with your project of interest.

Jeremy, this is fantastic, thank you for putting this together. 

Jeremy, I am currently trying to run this script in my own JIRA instance, but I am getting an error message. 


org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 15: expecting ')', found ';' @ line 15, column 26.
   if (versions != null && versions.size() > 0) {

1 error

 at Source)

Any idea why this could be? Current JIRA version is 7.2.7


Screen Shot 2017-05-02 at 5.01.32 PM.png

I am having the same issue. Is there an update for this?

Replace codes with real double amps.

I don't think there's a built-in way, though I think I could write an ad-hoc Script Runner script to do this fairly easily, and I actually have a use for that.  Do you want to sort numerically or alphanumerically?  I think the typical use case is by release date, which is why new versions are added to the top.

Thanks, I'd be looking for alpha numeric sort.  Our versions are generally numeric (01.02.03), but some have alpha characters (01.02.Beta).

I ask because, in an alpha-numeric sort, 02 comes before 1; in a numeric sort, 1 comes before 02, or such is my interpretation.  I suppose I could be making up the terminology; the unix "sort" utility also has "general numeric sort", which I'm not sure I understand, unless that's what I'm calling "alpha-numeric".

As long as everything is padded consistently, alpha-numeric sorting should work.  However, I think "Beta" would come after any numeric values.  Do you want non-numeric fields to come before numeric fields?  It seems like you'd want "Beta", then "01", etc.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence

Introducing External Collaboration for Confluence

We’re excited to introduce external collaboration for Confluence, now available in early access. It is available to preview for Confluence Cloud Premium and Enterprise customers. (If you're not on ...

191 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you