WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#3108 closed defect (bug) (fixed)

case insensitive array sorting

Reported by: mattyrob Owned by:
Milestone: Priority: lowest
Severity: trivial Version: 2.0.4
Component: Administration Keywords: has-patch
Focuses: Cc:

Description

Several arrays are sorted using ksort before being displayed in the admin section, examples include Plugins and Users & Authors.

ksort is a case sensitive method and as such all capitilised entries rank higher than non-capitalised entires.

Perhaps using:

uksort($myArray, "strnatcasecmp");

would allow all entires to be displayed aplhabetically.

I've tried this amendment in wp-admin/users.php and it worked for me.

Attachments (2)

3108.diff (1.8 KB) - added by Nazgul 8 years ago.
3108_20.diff (1.2 KB) - added by Nazgul 8 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 @masquerade8 years ago

Why not natcasesort()?

comment:2 @mattyrob8 years ago

natcasesort doesn't work in wp-admin.user.php
At line 375 there is a foreach statement as follows
foreach($roleclasses as $role => $roleclass) {

ksort($roleclass); current code
uksort($roleclass, "strnatcasecmp"); list of names appear in alphabetical order irrespective of case
natcasesort($roleclass); list appears in a very unusual order that I'm at a loss to explain

comment:3 @mattyrob8 years ago

Sorry about the above post it's been scrambled somewhat!

natcasesort doesn't work on my test installtion of version 2.1

ksort works but lists entires that are capitalised followed by those that are lower case.

uksort works as expected - all entires in one single a-z

natcasesort lists all entires but in an order that I cannot find an explanation for - and it certainly isn't a-z!

@Nazgul8 years ago

comment:4 @Nazgul8 years ago

  • Keywords has-patch added

Created a patch based on the given suggestions.

@Nazgul8 years ago

comment:5 @Nazgul8 years ago

  • Milestone changed from 2.1 to 2.0.5

Candidate for 2.0.5 inclusion.

comment:6 @markjaquith8 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [4289]) case insensitive sorting. props Nazgul. fixes #3108

comment:7 @markjaquith8 years ago

(In [4290]) case insensitive sorting. props Nazgul. fixes #3108

comment:8 @Viper007Bond8 years ago

Fuckin' yey! :D

The very first ticket I ever made (over a year ago) was on this subject. Even turned it into a plugin since people said "no way!" to my ticket. 'Bout time it finally got fixed. :)

comment:9 @Viper007Bond8 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Tsk tsk, not fixed. I have 3 plugins on my SVN plugins page and they are listed in this order:

Akismet
Hello Dolly
Example Login Form Plugin

Source for my plugin if it matters.

comment:10 @Viper007Bond8 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

Disregard. My first comment was before testing and my 2nd was before I realized that this was just better filename sorting. I really shouldn't look at code while so tired. :(

Although it would be nice to get true alphabetical plugins...

comment:11 @markjaquith8 years ago

Yeah, patch actually didn't address plugin sorting... but this next commit will.

The code to sort by plugin NAME (rather than filename) is in WP, but it's using the wrong function (uksort() instead of uasort()), so it won't work.

What's going to kill you is that plugin of yours will be made obsolete by a ONE CHARACTER CHANGE in WordPress core. :-D

comment:12 @anonymous8 years ago

  • Milestone 2.0.5 deleted

Milestone 2.0.5 deleted

Note: See TracTickets for help on using tickets.