php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19308 array_multisort() not always working...
Submitted: 2002-09-09 06:54 UTC Modified: 2002-09-09 07:46 UTC
From: yves at fuifbeest dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.2.2 OS: Linux
Private report: No CVE-ID: None
 [2002-09-09 06:54 UTC] yves at fuifbeest dot 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...

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-09 07:46 UTC] sniper@php.net
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.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Nov 28 05:01:27 2020 UTC