sort two diamensional array php

Solutions on MaxInterview for sort two diamensional array php by the best coders in the world

showing results for - "sort two diamensional array php"
Emilio
21 May 2020
1<?php
2
3$data=[
4  ['name'=>'Tamil',"distance"=>44],
5  ['name'=>'Tamil',"distance"=>4],
6  ['name'=>'Tamil',"distance"=>14],
7  ['name'=>'Tamil',"distance"=>24],  
8  ['name'=>'Tamil',"distance"=>10]
9];
10 
11 for($i=0;$i<count($data);$i++)
12 {
13    for($j=$i;$j<count($data);$j++)
14    {
15        if($data[$i]['distance']>$data[$j]['distance'])
16        {
17            $temp=$data[$i];
18            $data[$i]=$data[$j];
19            $data[$j]=$temp;
20        }
21    }
22 }
23 
24 print_r($data);
25
26#tamilarasan nallairsun