Skip to content

Instantly share code, notes, and snippets.

@frantzmiccoli
Created December 10, 2018 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frantzmiccoli/bd03395b8fc831c67828718192c214b8 to your computer and use it in GitHub Desktop.
Save frantzmiccoli/bd03395b8fc831c67828718192c214b8 to your computer and use it in GitHub Desktop.
Just a quick demo highlighting that PHP doesn't preserve same-value keys order while running an associative sort
<?php
$a = [];
$threshold = 120;
while (count($a) < 400) {
$v = count($a) > $threshold ? 'a' : 'b';
$a[] = $v;
}
asort($a);
// keys are preserved but their order within keys containing the same value is not.
var_dump($a);
die;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment