Does JQL not follow the customfield value sorting ?
Asked by Aisha M:

Hello,

I have a customfield that specifies different date increments (from 2020), no matter how I sort, the JQL always displays the oldest dates first .. .

Is there a way to fix this and make sure the JQL displays the field values exactly how I sort them ?


Answers:
author: Radek Dost?l
body: First off, what is the searcher of the custom field?

Look at custom fields - find it, click edit, the searcher is listed there.

Based on some of the values you posted in comment replies, I assume it is most likely a text searcher, or an option searcher.

Searchers typically work on how the values are stored.

If this was a date, imagine it as a milliseconds, lowest to highest, highest to lowest, no problem.

If this was a string, i.e. text, it will go character by character, from the first character, to the second, to the n, and if the character (which itself is a numeric value), lowest to greatest, greatest to lowest, etc. Same thing, but it goes character by character.

\^ this also applies to custom field values if your field is an option field

Now, what will happen if your values are:

9 X

19 X

20 X

Ascending, this would be 19, 20, 9 -- because it goes character by character, despite you knowing that 9 is less than 19.

If you use something called "natural" search or order (<https://en.wikipedia.org/wiki/Natural_sort_order>) then it will produce 9,19,20 because it takes care to treat numbers as whole, not by single character.

So I reckon, that you are using a searcher for the custom field, which probably doesn't care about the date at all, rather it cares about the sequence of characters in the values.

comments: author: Aisha M
body: [@Radek Dost?l](/t5/user/viewprofilepage/user-id/715713) Thank you for the detailed explanation. The searcher for the field is 'Multi Select searcher" . .

I want to add that while editing the issue, the sorting is exactly how it is configured. Only when querying in the JQL it lists the older values first

Is there any way this could be sorted so that the JQL searcher displays the field in the order of 2025,2024,2023,2022 ?


author: Radek Dost?l
body: Not without a "special" searcher, which I don't think I know of any.

If I understand how option searchers work then the only choice you have I'd say is to ensure that each value is in the same format.

E.g. always using 0's in case of 2-digit values, i.e. 01, 05, so that 11 and 25 are all in the correct order when sorted. Always using 4 digits for years, etc. So that indeed the sorting goes character by character and cannot fail on something missing between the values.

As a thought, just changing the value won't help, because it will need to re-index the values for jql to pick up on it (a single project re-index should work, but if you're using this with many then a full re-index will be better).

Without modifying the values, like I said it would need a custom searcher, one that Jira doesn't have natively (as far as I'm aware). It would have to supplied by a plugin, and associated with the field, some custom searcher that will treat the values in the "natural" order.

Just to be clear - the order of values in the context is ignored, it's just the values themselves.


author: Aisha M
body: Yes, you are right. I looked at the values and it is most probably sorting the values by the fourth character

PI 20.1

PI 21.1

PI 22.1

PI 23.1

PI 24.1

So based on this, the older years is coming first


author: Hannes Obweger - JXL for Jira
body: Hi [@Aisha M](/t5/user/viewprofilepage/user-id/1191523)

could you kindly provide a screenshot of what you are seeing in Jira, along with what you'd expect to see?

Thank you,

Best,

Hannes


author: Vikrant Yadav
body: Hi [@Aisha M](/t5/user/viewprofilepage/user-id/1191523) ,

You can Apply sorting on Date field as well.

![Screenshot 2024-09-16 at 1.12.48?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/347476i30BFDA202D721923/image-size/large?v=v2&px=999 "Screenshot 2024-09-16 at 1.12.48?PM.png")

comments: author: Aisha M
body: Thank you for the reply !

The field is a Select List field with values as below,

* PI 24.1 (01/04/24 - 03/13/24)
* PI 24.2 (03/14/24 - 05/22/24)
* PI 24.3 (05/23/24 - 07/31/24) \& so forth

I have sorted this list from 2025 - 2019 in the custom field

But, when I search for this field using the JQL, the values displayed start with 2019, it does not display the values as how it been sorted in the customfield configuration.


author: Vikrant Yadav
body: [@Aisha M](/t5/user/viewprofilepage/user-id/1191523) In Select list field sorting is done alphabetically by default.


author: Fabio Racobaldo _Herzum_
body: Hi [@Aisha M](/t5/user/viewprofilepage/user-id/1191523) ,

you should be able to sort jql result just clicking on a specific column and define order for that. Isn't it?

Fabio

comments: author: Aisha M
body: Thank you for the reply ! I not talking about the JQL result, but the field values displayed while using a JQL

The field is a Select List field with values as below,

* PI 24.1 (01/04/24 - 03/13/24)
* PI 24.2 (03/14/24 - 05/22/24)
* PI 24.3 (05/23/24 - 07/31/24) \& so forth

I have sorted this list from 2025 - 2019 in the custom field

But, when I search for this field using the JQL, the values displayed start with 2019, it does not display the values as how it been sorted in the customfield configuration.


Tags: data-center

jira-data-center