Skip to content

Instantly share code, notes, and snippets.

@frantzmiccoli
Created December 10, 2018 15:25
Show Gist options
  • 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