Ticket #3108 (closed defect: fixed)

Opened 2 years ago

Last modified 1 year ago

case insensitive array sorting

Reported by: mattyrob Assigned to: anonymous
Priority: lowest Milestone:
Component: Administration Version: 2.0.4
Severity: trivial Keywords: has-patch
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

3108.diff (1.8 kB) - added by Nazgul on 09/29/06 20:49:00.
3108_20.diff (1.2 kB) - added by Nazgul on 10/04/06 03:23:40.

Change History

09/05/06 19:35:10 changed by masquerade

Why not natcasesort()?

09/17/06 12:48:02 changed by mattyrob

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

09/17/06 12:53:30 changed by mattyrob

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!

09/29/06 20:49:00 changed by Nazgul

  • attachment 3108.diff added.

09/29/06 20:49:55 changed by Nazgul

  • keywords set to has-patch.

Created a patch based on the given suggestions.

10/04/06 03:23:40 changed by Nazgul

  • attachment 3108_20.diff added.

10/04/06 03:24:08 changed by Nazgul

  • milestone changed from 2.1 to 2.0.5.

Candidate for 2.0.5 inclusion.

10/04/06 03:49:59 changed by markjaquith

  • status changed from new to closed.
  • resolution set to fixed.

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

10/04/06 03:50:16 changed by markjaquith

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

10/04/06 06:39:06 changed by Viper007Bond

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. :)

10/04/06 07:55:31 changed by Viper007Bond

  • status changed from closed to reopened.
  • resolution deleted.

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.

10/04/06 08:40:03 changed by Viper007Bond

  • status changed from reopened to closed.
  • resolution set to fixed.

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...

10/04/06 08:54:15 changed by markjaquith

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

11/30/06 19:41:51 changed by

  • milestone deleted.

Milestone 2.0.5 deleted