- print_r: documentation ( source)
- usort: documentation ( source)
<?php
$arr = [
new StdClass,
new StdClass,
new StdClass,
];
$arr[0]->path_to_file = "roberson_wine_5";
$arr[0]->order = 2;
$arr[1]->path_to_file = "roberson_wine_5";
$arr[1]->order = 3;
$arr[2]->path_to_file = "roberson_wine_3";
$arr[2]->order = 1;
print_r($arr);
usort($arr, function($a, $b){
if($a->order == $b->order)
return 0;
return $a->order > $b->order ? 1: -1;
});
print_r($arr);