[wp-trac] [WordPress Trac] #20733: Theme customizer doesn't order sections based on order added

WordPress Trac wp-trac at lists.automattic.com
Thu May 24 01:04:55 UTC 2012


#20733: Theme customizer doesn't order sections based on order added
--------------------------+------------------
 Reporter:  andyadams     |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  3.4
Component:  Appearance    |     Version:  3.4
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |
--------------------------+------------------

Comment (by nacin):

 Just so everyone is aware of why this is happening, PHP's user-sorting
 algorithm does not guarantee the original order of the array:
 http://php.net/usort. "If two members compare as equal, their relative
 order in the sorted array is undefined." and "The cmp_function doesn't
 keep the original order for elements comparing as equal."

 We avoid these issues in the plugin API (and elsewhere) by keying things
 by priority. Or we could do the sorting ourself by simply looping through
 the elements and adding them to an array keyed by priority. Not
 necessarily the best idea here. Some kind of array_search is probably
 isn't going to be the fastest, but seems reasonable enough.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/20733#comment:8>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list