How could I sort a defined array based on another array? In our CMS, we have a form that uses the jQuery sortable widget to sort the rows in the form. The form rows are initially created with a multidimensional array. Upon saving, the data is saved in a serialized array. So whenever you sort the rows and save, the data is saved in that "sorted" order, which is how it should be. The problem we're hitting is the form is still output in the order from the original array, not the saved, sorted array.
Would there be a way to sort the original array in the order of the saved, sorted array?
Here's how the original array and order looks:
Array
(
[group-1] => Array
(
[fields] => Array
(
[name] => Array
(
[type] => text
[name] => Full Name
)
[email-address] => Array
(
[type] => text
[name] => Email Address
)
)
)
[group-2] => Array
(
[fields] => Array
(
[address] => Array
(
[type] => text
[name] => Address
)
)
)
[group-3] => Array
(
[fields] => Array
(
[city] => Array
(
[type] => text
[name] => City
)
[zip] => Array
(
[type] => text
[name] => Zip
)
)
)
)
And here is the sorted saved data
Array
(
[group-3] => Array
(
[city] => Apples
[zip] => 12345
)
[group-1] => Array
(
[name] => Tigre Woodrow
[email-address] => [email protected]
)
[group-2] => Array
(
[address] => 1234 Anywhere Street
)
)
So from the arrays, the rows of fields are the group id's there. Would there be a way to sort based on that group id?
usort
. – mc10 Jan 31 at 1:25