#19308 [Opn->Bgs]: array_multisort() not always working...

From: Date: Mon, 09 Sep 2002 12:46:18 +0000
Subject: #19308 [Opn->Bgs]: array_multisort() not always working...
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-18773@lists.php.net to get a copy of this message
ID: 19308 Updated by: sniper@php.net Reported By: yves@fuifbeest.com -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: Linux PHP Version: 4.2.2 New Comment: Thank you for taking the time to report a problem with PHP. Unfortunately you are not using a current version of PHP -- the problem might already be fixed. Please download a new PHP version from http://www.php.net/downloads.php If you are able to reproduce the bug with one of the latest versions of PHP, please change the PHP version on this bug report to the version you tested and change the status back to "Open". Again, thank you for your continued support of PHP. Previous Comments: ------------------------------------------------------------------------ [2002-09-09 06:54:06] yves@fuifbeest.com 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 this bug report at http://bugs.php.net/?id=19308&edit=1

« previous php.bugs (#18773) next »