$data = [ ['name'=>'Arai', 'score'=>30], ['name'=>'Inoue', 'score'=>40], ['name'=>'Utada', 'score'=>30], ['name'=>'Okuda', 'score'=>40], ['name'=>'Kato', 'score'=>23] ]; // record for ($i = 0; $i < count($data); i++){ $data[$i]["id"] = $i + 1; } usort($data, function($a, $b){ if ($a['score'] == $b['score']){ return ($a['id'] > $b['id']) ? 1 : -1; }); foreach ($data as $u){ echo $u['id'].":".$u['name'].":".$u['score']."\n"; }