![]() |
sorting arrays - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: sorting arrays (/showthread.php?tid=18817) |
sorting arrays - El Forum - 05-19-2009 [eluser]new_igniter[/eluser] Hello I have a set of arrays I build like this: Code: $authorStreamArray[] = array($acount,$username,$userPic,$numFollowers); I then want to sort this according to $acount Can someone help me to understand the best way to do this? I have tried diff stuff, but I would love to know how y'all do it. sorting arrays - El Forum - 05-19-2009 [eluser]Dam1an[/eluser] Have you looked at array multisort? sorting arrays - El Forum - 05-19-2009 [eluser]new_igniter[/eluser] yes, Im kind of a noob, so I dont really understand what is really going on there from the examples. sorting arrays - El Forum - 05-19-2009 [eluser]Dam1an[/eluser] I'm impressed... a self classed noob that read the PHP manual? Next you'll be telling me you've read the user guide ![]() The easiest thing to do, is to try a few examples yourself till you get the result you want. Its much better to learn by doing 9and getting it wrong first) then by just reading (although you should read as well) examples and copy & pasting it sorting arrays - El Forum - 05-19-2009 [eluser]new_igniter[/eluser] Cool. on this Code: // Obtain a list of columns if I have 4 keys, do I need to list them all? sorting arrays - El Forum - 05-19-2009 [eluser]new_igniter[/eluser] when I do it the way shown below, I get: Warning: array_multisort() [function.array-multisort]: Argument #3 is expected to be an array or a sort flag Code: foreach ($authorStreamArray as $key => $row) { sorting arrays - El Forum - 05-19-2009 [eluser]new_igniter[/eluser] ok, this seems to work well: Code: foreach ($authorStreamArray as $key => $row) { |