Sorting multi-dimensional arrays

From: Date: Mon, 30 Oct 2000 14:52:31 +0000
Subject: Sorting multi-dimensional arrays
Groups: php.general 
Request: Send a blank email to php-general+get-22686@lists.php.net to get a copy of this message
Is there a way to sort a multi-dimensional array by a specified collumn? ex. if i want to sort by the 3rd row: /=== | $ar = array( array( 23, 'kjhsdfjhd', 952106215, 'jkhg' ), | array( 24, 'zmncjdflf', 952103423, 'fgfg' ) ); | sort_multi_array_by_col( $ar, 2 ); \=== and then i get: $ar[0] => [ 24, 'zmncjdflf', 952103423, 'fgfg' ] $ar[1] => [ 23, 'kjhsdfjhd', 952106215, 'jkhg' ] Or perhaps by key-name: /=== | $ar = array( array( "name" => "John", "telephone" => "555-4321" ), | array( "name" => "Bob", "telephone" => "555-1234" ) ); | sort_multi_array_by_col( $ar, "telephone" ); \=== -Tobias-

« previous php.general (#22686) next »