#19308 [NEW]: array_multisort() not always working...
| From: | yves at fuifbeest dot com | Date: | Mon, 09 Sep 2002 11:54:06 +0000 |
| Subject: | #19308 [NEW]: array_multisort() not always working... | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-18758@lists.php.net to get a copy of this message | ||
From: yves@fuifbeest.com
Operating system: Linux
PHP version: 4.2.2
PHP Bug Type: Arrays related
Bug description: array_multisort() not always working...
I'm rather sure that compiling or OS options won't have anything to do with
this problem, so I'll ignore them. In case you guys might think I've done
something special when setting up the server or PHP, it's not that. I've
encountered this problem on a "big" hosting firm's server, and after one
year of usage, I can tell you they don't do any exotic things with their
servers. So here's the problem:
I've got an array like this:
$arr[0][13][1031562973] = "HTML-code, nothing special";
$arr[1][1][1031520353] = "HTML-code, nothing special";
$arr[2][1][1031562923] = "HTML-code, nothing special";
The first key of this array was generated in a while-loop, by doing
$arr[][... and so on... The second key is the number of posts on a forum,
the 3rd key is a unix-timestamp...
The thing I wanted to do is sorting the array, first on the number of
posts, and then on the unix-time. I found in the manual the function
array_multisort() which seem to solve my problem. I called it in several
ways, most of them pratically the same, but I shall report these 2:
array_multisort ($arr[1], SORT_DESC, SORT_NUMERIC, $arr[2], SORT_DESC,
SORT_NUMERIC);
and
array_multisort (&$arr[1], SORT_DESC, SORT_NUMERIC, &$arr[2], SORT_DESC,
SORT_NUMERIC);
But while trying over and over again, I found out that this function
wasn't doing anything! No sorting at all, the array remained untouched...
Maybe this problem is caused because I don't use the first column for
sorting, but the manual doesn't say anything about this, so I don't think
it's required to do so...
Sorry if this bug is a bogus one, but I really don't know what I'm doing
wrong...
--
Edit bug report at http://bugs.php.net/?id=19308&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=19308&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=19308&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=19308&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=19308&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=19308&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=19308&r=support
Expected behavior: http://bugs.php.net/fix.php?id=19308&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=19308&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=19308&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=19308&r=globals