[buddypress-trac] [BuddyPress Trac] #7238: Change bp_sort_by_key() to allow key preservation.
buddypress-trac
noreply at wordpress.org
Thu Sep 8 21:07:53 UTC 2016
#7238: Change bp_sort_by_key() to allow key preservation.
------------------------------+-----------------------
Reporter: dcavins | Owner: dcavins
Type: enhancement | Status: accepted
Priority: normal | Milestone: 2.7
Component: Core | Version: 2.2
Severity: normal | Resolution:
Keywords: has-patch commit |
------------------------------+-----------------------
Comment (by dcavins):
Well, this is interesting. Simply changing `usort()` out for `uasort()`
seems to work OK for our uses of `bp_sort_by_key()`, but we've got a test
that sorts an object that breaks:
https://buddypress.trac.wordpress.org/browser/trunk/tests/phpunit/testcases/core/functions.php#L295
Other tests of non-assocative arrays that also fail can be fixed like this
(`assertEquals` compares keys, values and order):
`$this->assertEquals( $expected, array_values( bp_sort_by_key( $items,
'value', 'num' ) ) );`
Is that test sorting an object a good case for keeping `usort()`, or is it
testing an unlikely use of `bp_sort_by_key()`?
Opinions welcome! :)
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/7238#comment:7>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list