Di bawah adalah contoh melakukan sorting berdasar elemen array tertentu PHP: <?php// Data yang akan diurutkan, berupa array$data = array( array( 'umur' => 31, 'nama' => 'Anton', 'email' => '[email protected]' ), array( 'umur' => 27, 'nama' => 'Andika', 'email' => '[email protected]' ), array( 'umur' => 31, 'nama' => 'Amanda', 'email' => '[email protected]' ), array( 'umur' => 33, 'nama' => 'Amanda', 'email' => '[email protected]' ), array( 'umur' => 17, 'nama' => 'Amanda', 'email' => '[email protected]' ), array( 'umur' => 56, 'nama' => 'Wisnu', 'email' => '[email protected]' ), array( 'umur' => 41, 'nama' => 'Asep', 'email' => '[email protected]' ));// Urutkan berdasar umur, baru nama.function umur_nama($a, $b) { if ($a['umur'] < $b['umur']) { return -1; } if ($a['umur'] > $b['umur']) { return 1; } $i = strcasecmp($a['nama'], $b['nama']); return $i;}// Urutkan berdasar nama, baru umur.function nama_umur($a, $b) { $i = strcasecmp($a['nama'], $b['nama']); if (0 == $i) { if ($a['umur'] < $b['umur']) { return -1; } if ($a['umur'] > $b['umur']) { return 1; } } return $i;}// Proses sorting$data1 = $data2 = $data;usort($data1, 'umur_nama');usort($data2, 'nama_umur');// Cek isi arrayecho '<pre>';print_r($data1);print_r($data2);echo '</pre>';?>