|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65709 Sorting an array gives different outputs when intl is enabled
Submitted: 2013-09-19 11:54 UTC Modified: 2016-04-24 04:22 UTC
Avg. Score:4.9 ± 0.3
Reproduced:7 of 7 (100.0%)
Same Version:6 (85.7%)
Same OS:5 (71.4%)
From: info at arnoldpistorius dot com Assigned:
Status: No Feedback Package: intl (PECL)
PHP Version: 5.5.3 OS: CENTOS 6.3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
50 - 42 = ?
Subscribe to this entry?

 [2013-09-19 11:54 UTC] info at arnoldpistorius dot com
I am trying to sort an array containing file names with SORT_LOCALE_STRING. 
However the result is not consistent when I refresh the page several times. It 
appears to be that the output randomly differs.

This behaviour is only occuring when PHP is compiled with intl (--enable-intl) or 
the pecl extension intl is installed. I foudn this out when I was experiencing 
different behaviour on scandir, which does also a sort.

You can reproduce the problem by executing the following script several times by 
pressing F5 in your browser.

Test script:
setlocale(LC_ALL, 'NL_nl');
$files = array('__Abstract.js', '', 'Delete.js', '', 'Copy.js', '');

sort($files, SORT_LOCALE_STRING);

Expected result:
The script should always have the same output

Actual result:
 Most of the times I get the following output:

array (
  0 => '.',
  1 => '..',
  2 => '',
  3 => '__Abstract.js',
  4 => '',
  5 => 'Copy.js',
  6 => '',
  7 => 'Delete.js',

But now and then the output is:

array (
  0 => '.',
  1 => '..',
  2 => '',
  3 => 'Copy.js',
  4 => '',
  5 => 'Delete.js',
  6 => '',
  7 => '__Abstract.js',


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-09-19 12:00 UTC] info at arnoldpistorius dot com
-: info at arnoldpistoirus dot com +: info at arnoldpistorius dot com
 [2013-09-19 12:00 UTC] info at arnoldpistorius dot com
Corrected e-mail address typo
 [2016-04-12 13:27 UTC]
-Status: Open +Status: Feedback
 [2016-04-12 13:27 UTC]
Thanks for the report. I don't reproduce the random sort issue with your snippet. Furthermore, the actual result looks different from what it should output. Please provide a reliable snippet for this.

 [2016-04-24 04:22 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Dec 06 07:01:27 2023 UTC