Bug #79868 [Opn->Fbk]: Sorting with array_unique gives unwanted result

From: Date: Sat, 18 Jul 2020 11:26:27 +0000
Subject: Bug #79868 [Opn->Fbk]: Sorting with array_unique gives unwanted result
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228106@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79868&edit=1

 ID:                 79868
 Updated by:         sjon@php.net
 Reported by:        dries at vints dot io
 Summary:            Sorting with array_unique gives unwanted result
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            *General Issues
 Operating System:   macOS Catalina 10.15.5
 PHP Version:        8.0.0alpha2
-Assigned To:        
+Assigned To:        sjon
 Block user comment: N
 Private report:     N

 New Comment:

can you explain why "Illuminate\Routing" should be sorted before
"Illuminate\Auth" ?


Previous Comments:
------------------------------------------------------------------------
[2020-07-17 15:22:28] dries at vints dot io

Description:
------------
Sorting with array_unique returns different results than in previous PHP versions. I suspect this is
because of https://wiki.php.net/rfc/stable_sorting

If you run the test script from below it'll return the result seeing in https://3v4l.org/9sbAq

Test script:
---------------
var_dump(array_unique([
    'Illuminate\Routing\Middleware\SubstituteBindings',
    'Illuminate\Auth\Middleware\Authorize:edit,post',
], SORT_REGULAR));

Expected result:
----------------
array(2) {
  [0]=>
  string(48) "Illuminate\Routing\Middleware\SubstituteBindings"
  [1]=>
  string(46) "Illuminate\Auth\Middleware\Authorize:edit,post"
}

Actual result:
--------------
array(2) {
  [1]=>
  string(46) "Illuminate\Auth\Middleware\Authorize:edit,post"
  [0]=>
  string(48) "Illuminate\Routing\Middleware\SubstituteBindings"
}


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=79868&edit=1


Thread (7 messages)

« previous php.bugs (#228106) next »