Livewire orders select options alphabetially automatically?

I have an array in PHP like this:

[
    '1' => 'City 1',
    '3' => 'City 3',
    '2' => 'City 2',
]

When I pass this to Livewire and loop through the options like this:

<select wire:model.lazy="city" class="form-row">
    @foreach ($cities as $id => $name)
        <option value="{{ $id }}" wire:key="{{ $id }}">{{ $name }}</option>
    @endforeach
</select>

It always outputs the options ordered alphabetically by key, but I want them like in the array above. What is the issue and how to resolve it?

If you need them in that order I’d recommend instead of having an array of [$id => $name] you change it to [$index => [‘id’ => $id, ‘name’ => $name]] that way you’re $index will control the order of the results and then you can access the id and value from the sub-array to populate your options list.