<?php
$unordered = array("second" => 2, "first" => 1, "third" =>3);
$ordered = array("first", "second", "third");
$sorted = array();
foreach($ordered as $order)
{
$sorted[$order] = $unordered[$order];
}
<?php
$unordered = array("second" => 2, "first" => 1, "third" =>3);
$ordered = array("first", "second", "third");
$sorted = array();
foreach($ordered as $order)
{
$sorted[$order] = $unordered[$order];
}