I am working on an InertiaJS project.
I have a PHP array which pass it as a prop to Vue and show it as a select box. Here's how the object is in JS:
{
1: "Vexapa",
5: "Linga & Satro",
6: "Feearlees",
7: "Abbaga, Sort and Try",
8: "Ollwether",
10: "Domino Effect",
11: "Sapata",
12: "Ankels' Camel",
18: "Katrina SHA",
19: "Ulusy",
20: "Whatever"
}
I want this object sorted ascending by value, from A to Z.
I have tried other solutions like this one Sort objects in an array alphabetically on one property of the array
but nothing seem to work. Whatever I do, the moment I have to convert it to an object, the ordering goes by the key.
Even if I sort in the back-end, in the JS the object is again sorted by ID.
I know that in ES6 objects are sorted by default.
I have also tried it with lodash but with no luck.