{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/9600","labels_url":"https://api.github.com/repos/laravel/framework/issues/9600/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/9600/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/9600/events","html_url":"https://github.com/laravel/framework/pull/9600","id":94590052,"number":9600,"title":"Improvements to Arr::sortRecursive","user":{"login":"mzur","id":2457311,"avatar_url":"https://avatars.githubusercontent.com/u/2457311?v=3","gravatar_id":"","url":"https://api.github.com/users/mzur","html_url":"https://github.com/mzur","followers_url":"https://api.github.com/users/mzur/followers","following_url":"https://api.github.com/users/mzur/following{/other_user}","gists_url":"https://api.github.com/users/mzur/gists{/gist_id}","starred_url":"https://api.github.com/users/mzur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mzur/subscriptions","organizations_url":"https://api.github.com/users/mzur/orgs","repos_url":"https://api.github.com/users/mzur/repos","events_url":"https://api.github.com/users/mzur/events{/privacy}","received_events_url":"https://api.github.com/users/mzur/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-07-12T18:39:55Z","updated_at":"2015-07-13T09:56:58Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/laravel/framework/pulls/9600","html_url":"https://github.com/laravel/framework/pull/9600","diff_url":"https://github.com/laravel/framework/pull/9600.diff","patch_url":"https://github.com/laravel/framework/pull/9600.patch"},"body":"I've recently encountered a few issues with `Arr::sortRecursive` so I'd like to propose some improvements to this function. These issues were:\r\n\r\n**Recursion stops if an array containing the key `0` is encountered:**\r\n\r\nArray | Expected result | Actual result\r\n------- | ------------------- | ---------------\r\n`[['b' => 'x', 'a' => 'x']]` | `[['a' => 'x', 'b' => 'x']]` | `[['b' => 'x', 'a' => 'x']]`\r\n\r\n**Flat arrays were not sorted:**\r\n\r\nArray | Expected result | Actual result\r\n------- | ------------------- | ---------------\r\n`['b', 'a']` | `['a', 'b']` | `['b', 'a']`\r\n\r\nTo improve recognizing of \"non-associative\" arrays (having incrementing numerical keys starting with 0), I've added an `Arr::isAssoc` method.\r\n\r\nThe general behavior is now as follows:\r\nEvery \"non-associative\" array (like `[3, 2, 1]`) is sorted by values using `sort()`. Every \"associative\" array (like `['b' => 1, 'a' => 5]`) is sorted by keys using `ksort()`. The array is now passed by reference (to be consistent with functions like `sort` or `ksort`; also for the recursion to work properly) but the sorted array is returned, too (for compatibility reasons).\r\n\r\n**Edit:** The test fails with PHP 7; I'll look into it."},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/120878303","html_url":"https://github.com/laravel/framework/pull/9600#issuecomment-120878303","issue_url":"https://api.github.com/repos/laravel/framework/issues/9600","id":120878303,"user":{"login":"GrahamCampbell","id":2829600,"avatar_url":"https://avatars.githubusercontent.com/u/2829600?v=3","gravatar_id":"","url":"https://api.github.com/users/GrahamCampbell","html_url":"https://github.com/GrahamCampbell","followers_url":"https://api.github.com/users/GrahamCampbell/followers","following_url":"https://api.github.com/users/GrahamCampbell/following{/other_user}","gists_url":"https://api.github.com/users/GrahamCampbell/gists{/gist_id}","starred_url":"https://api.github.com/users/GrahamCampbell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GrahamCampbell/subscriptions","organizations_url":"https://api.github.com/users/GrahamCampbell/orgs","repos_url":"https://api.github.com/users/GrahamCampbell/repos","events_url":"https://api.github.com/users/GrahamCampbell/events{/privacy}","received_events_url":"https://api.github.com/users/GrahamCampbell/received_events","type":"User","site_admin":false},"created_at":"2015-07-13T09:56:58Z","updated_at":"2015-07-13T09:56:58Z","body":"This doesn't work on php 7. You must make sure this works on php 7."}}