# Bug OP-15724 - Custom field with format „Version“ are ordered as strings

Project: OpenProject
Status: closed
URL: https://community.openproject.org/work_packages/OP-15724

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module |  |
| Target versions | 15.0.0 |
| Observed in versions | 14.4.0 |
| Sprint | 15.0.0 |
| Backlog bucket |  |
| Bug found in version (deprecated) | 14.4.x |
| Found in mobile app version |  |
| Follow-up feedback e-mail |  |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee | Ivan Kuchin |
| Accountable | Ivan Kuchin |
| Product manager |  |
| Developers |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

| Attribute | Value |
| --- | --- |
| Relevance |  |

## Costs

| Attribute | Value |
| --- | --- |
| Votes |  |
| Work |  |
| Labor costs |  |

## Description

### Steps to reproduce

1.  Create versions `10.10.10`, `10.10.2`, `10.2`, `9`
    
2.  Create project attribute with format version
    
3.  Create projects for every created version, enable the attribute and set the attribute value
    
4.  Go to index page and order by the project attribute
    

### What is the buggy behaviour?

*   Projects with attribute set are ordered alphabetically
    

### What is the expected behaviour?

*   Projects should be ordered by version, so `9`, `10.2`, `10.10.2`, `10.10.10` should be the ascending order
    

### Note

There is already handling of semver ordering in `app/models/versions/scopes/order_by_semver_name.rb`

This can be solved by using a collation:

```sql
WITH vals(v) AS (VALUES ('10.10.10'), ('10.10.2'), ('10.2'), ('9')) SELECT * FROM vals order by v;
 10.10.10
 10.10.2
 10.2
 9
CREATE COLLATION numeric (provider = icu, locale = 'en_US.UTF-8@colNumeric=yes');
WITH vals(v) AS (VALUES ('10.10.10'), ('10.10.2'), ('10.2'), ('9')) SELECT * FROM vals order by v COLLATE numeric;
 9
 10.2
 10.10.2
 10.10.10
```
