# Bug OP-11007 - "Reorder values alphabetically" does not work reliably

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

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module |  |
| Target versions | 12.3.1 |
| Observed in versions | 12.0.0 |
| Sprint | 12.3.1 |
| Backlog bucket |  |
| Bug found in version (deprecated) | 12.0.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 |  |
| Accountable |  |
| 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 a custom list field with a lot of choices
2.  Click on sort alphabetically

### What is the buggy behavior?

*   List of possible values is not ordered alphabetically

### What is the expected behavior?

*   List of possible values is ordered alphabetically

### Work-around

*   click on &quot;sort alphabetically&quot; multiple times preserves already sorted areas and sort some values, so enough clicks will eventually solve the problem :-D

### Quick-Fix via Database

```sql
UPDATE custom_options SET position = (
  SELECT new_position
  FROM (
    SELECT *, ROW_NUMBER() OVER (PARTITION BY custom_field_id ORDER BY value) AS new_position
    FROM custom_options
  ) AS B
  WHERE B.id=custom_options.id
);
```

### Screenshots and other files

<img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/37898/content">

### Environment information

Since v12.0

**OpenProject installation type**

*   [ ] Hosted cloud edition
*   [x] Packaged installation
    *   What distribution? Debian
*   [ ] Docker All-in-one container
*   [ ] Docker-compose installation
*   [ ] Other (please specify)

**OpenProject version**

_v_**12.1.6**

**Browser**

*   [x] Edge
*   [ ] Chrome
*   [ ] Firefox
*   [ ] Safari
*   [ ] Mobile Safari
*   [ ] Other (please specify)

**Language**

German
