Forum Moderators: coopster

Message Too Old, No Replies

Easy way to do a 2d array sort.on rows instead of columns?

         

smithaa02

4:50 pm on May 19, 2011 (gmt 0)

10+ Year Member



PHP has a function called array_multisort that sorts on columns instead of rows. Now I can flip the array, but was just wondering if there was an easier solution?

Seems to be this would be a common issue with DB results...you would assign your mysql_query results to a 2d array but sort things the opposite of how array_multisort wants to do this.

Any tricks?

rocknbil

6:11 pm on May 20, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not to sidestep the exploration of the array, but you said "DB" - chances are pretty good that this doesn't happen often because any sorting is resolved at the database level with robust sorting statements. Back up a step and show us how you're selecting from the DB and why you need a two dimensional array?