it probably safer to use array_multisort as if the array has 2 values for $explode[2] the same as in my example the one will be over written
echo '<pre>';
$array = $array2 = array(
'123|Abc|8|',
'456|Def|2|',
'789|Ghi|2|',
'012|Jkl|1|',
'345|Mno|6|'
);
foreach ($array as $value)
{
$explode = explode('|', $value);
$new_array[$explode[2]] = $value;
//create array to sort by in multi sort
$newarray[]=$explode[2];
}
ksort($new_array);
print_r($new_array);
array_multisort($newarray,$array2);
print_r($array2);
echo '</pre>';
output
Array
(
[1] => 012|Jkl|1|
[2] => 789|Ghi|2|
[6] => 345|Mno|6|
[8] => 123|Abc|8|
)
Array
(
[0] => 012|Jkl|1|
[1] => 456|Def|2|
[2] => 789|Ghi|2|
[3] => 345|Mno|6|
[4] => 123|Abc|8|
)