Page 1 of 1

Multi-dimensional array sort help.

Posted: Wed May 21, 2003 3:50 pm
by rxsid
Hi all,

I have an array i'm capturing from a textarea on a form.

Each line has this format:

Code: Select all

varA (space) varB|varC
I'm trying to ensure that this array is sorted by VarB DESC before I place it into a text file.

Here what I have:

Code: Select all

$array = split("\n",$listItems);
$count = count($array);
for ($x = 0;$x<$count; $x++) {
  list($varX,$varC) = split("\|",$array[$x]);
  list($varA,$varB) = split(" ",$varX);
}
$sortedArray = array_multisort($varB,SORT_STRING,SORT_DESC, $varA,$varC);
  echo $sortedArray;
Of course this doesn't work (the multisort part). I am splitting my elements the way I need to so that's not the issue.

Some of the examples I've seen have the array_multisort() inside the for loop. I can't get it to work.

Can someone point me in the right direction please?

Thanks!