I'm currently working on a project using InertiaJS.
I have a PHP array that I pass as a prop to Vue and display it as a select box. Here's what the object looks like in JavaScript:
{
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"
}
My goal is to have this object sorted in ascending order by value, from A to Z.
I've tried various solutions similar to the one found here
but none of them seem to be working. Regardless of what I try, whenever I convert it to an object, the sorting is based on the key.
Even if I attempt to sort it in the back-end, in JavaScript the object still ends up sorted by ID.
I'm aware that ES6 objects are normally sorted by default.
I've also attempted to use lodash for this task, but unfortunately, without success.