Skip to content

Dictionary loses option order when values are integers #14873

Description

@helloiamlukas

Bug description

The order of options returned by a dictionary is not preserved in the Control Panel. The dropdown shows them in a different order than the dictionary defines. This only seems to happen when the option keys/values are numbers, where they end up sorted ascending instead of keeping the dictionary's order.

Options defined in the dictionary:

    protected function getItems(): array
    {
        return [
            ['id' => '123', 'description' => '123 Shoes'],
            ['id' => '1', 'description' => '1 Shirt'],
            ['id' => '7', 'description' => '7 Hats'],
            ['id' => '5', 'description' => '5 Pants'],
        ];
    }

Options shown in the CP:

Image

How to reproduce

  1. Clone repository: https://github.com/helloiamlukas/dictionary-options-wrong-order
  2. Open /cp/collections/articles/entries/7ac0bdda-1b84-45f8-ac52-2575dd7e8251
  3. Open the dropdown of the "Products" field

Logs

Environment

Environment
Laravel Version: 13.17.0
PHP Version: 8.3.22
Composer Version: 2.9.7
Environment: local
Debug Mode: ENABLED
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: sqlite
Logs: stack / single
Mail: log
Queue: sync
Session: file

Storage
public/storage: NOT LINKED

Statamic
Addons: 0
License Key: Not set
Sites: 1
Stache Watcher: Enabled (auto)
Static Caching: Disabled
Version: 6.23.0 Solo

Installation

Starter Kit using via CLI

Additional details

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions