monk.e.boy Posted March 29, 2007 Share Posted March 29, 2007 Hello, How would I go about sorting the following array? $t= array(); $t[] = array( 'text 2', 1, 2 ); $t[] = array( 'text 4', 2, 1 ); $t[] = array( 'text 1', 1, 1 ); $t[] = array( 'text 5', 2, 2 ); $t[] = array( 'text 3', 1, 3 ); // sort and get: $t[] = array( 'text 1', 1, 1 ); $t[] = array( 'text 2', 1, 2 ); $t[] = array( 'text 3', 1, 3 ); $t[] = array( 'text 4', 2, 1 ); $t[] = array( 'text 5', 2, 2 ); I guess this is like an SQL ORDER BY col1, col2 Anyone know if there is an easy way to do this in PHP? cheers monk.e.boy Link to comment https://forums.phpfreaks.com/topic/44759-solved-sorting-arrays/ Share on other sites More sharing options...
monk.e.boy Posted March 29, 2007 Author Share Posted March 29, 2007 $t[] = array( 1, 2, 'text 2' ); $t[] = array( 2, 1, 'text 4' ); $t[] = array( 1, 1, 'text 1' ); $t[] = array( 2, 2, 'text 5' ); $t[] = array( 1, 3, 'text 3' ); sort( $t ); That seems to work I answered my own question (hehe) monk.e.boy Link to comment https://forums.phpfreaks.com/topic/44759-solved-sorting-arrays/#findComment-217330 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.