Antivirus
05-12-2008, 02:16 AM
I have always done all my sorting of data within the sql query, however for once, i need to do it in php and since ive never done this in php, i'm a bit stumped, hoping someione can assist...
My array looks like this:
Array
(
[0] => Array
(
[groupid] => 66
[name] => SOTE
[description] => Lorem ipsum dolor sit amet
[sc_ispd] => 1
[dateline] => 1204247554
)
[1] => Array
(
[groupid] => 88
[name] => LOS
[description] => Lorem ipsum dolor sit amet
[sc_ispd] => 0
[dateline] => 1204779261
)
[2] => Array
(
[groupid] => 1
[name] => MEGA
[description] => Lorem ipsum dolor sit amet
[sc_ispd] => 1
[dateline] => 1202601980
)
[3] => Array
(
[groupid] => 86
[name] => CRABS
[description] => Lorem ipsum dolor sit amet
[sc_ispd] => 1
[dateline] => 1204777825
)
)
What I need to do is re-sort it as if doing the sort in sql like so:
ORDER BY sc_ispd DESC, dateline DESC, groupid DESC
I'm pretty sure i need to use array_multisort() to do this, but having some difficulty with it. Is it even possible to do what i am trying to do here?
My array looks like this:
Array
(
[0] => Array
(
[groupid] => 66
[name] => SOTE
[description] => Lorem ipsum dolor sit amet
[sc_ispd] => 1
[dateline] => 1204247554
)
[1] => Array
(
[groupid] => 88
[name] => LOS
[description] => Lorem ipsum dolor sit amet
[sc_ispd] => 0
[dateline] => 1204779261
)
[2] => Array
(
[groupid] => 1
[name] => MEGA
[description] => Lorem ipsum dolor sit amet
[sc_ispd] => 1
[dateline] => 1202601980
)
[3] => Array
(
[groupid] => 86
[name] => CRABS
[description] => Lorem ipsum dolor sit amet
[sc_ispd] => 1
[dateline] => 1204777825
)
)
What I need to do is re-sort it as if doing the sort in sql like so:
ORDER BY sc_ispd DESC, dateline DESC, groupid DESC
I'm pretty sure i need to use array_multisort() to do this, but having some difficulty with it. Is it even possible to do what i am trying to do here?