Development

Changeset 33390

You must first sign up to be able to contribute.

Changeset 33390

Show
Ignore:
Timestamp:
03/21/12 22:12:23 (2 years ago)
Author:
boutell
Message:

Tags should be sorted in a case-insensitive fashion for consistency with the results of sorting them with MySQL and for general friendliness

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfDoctrineActAsTaggablePlugin/trunk/lib/model/doctrine/PluginTagTable.class.php

    r32923 r33390  
    177177        if (!isset($options['sort_by_popularity']) || (true !== $options['sort_by_popularity'])) 
    178178        { 
    179             ksort($tags); 
     179            uksort($tags, array('TagTable', 'compareTags')); 
    180180        } 
    181181 
    182182        return $tags; 
     183    } 
     184 
     185    /** 
     186     * Case insensitive comparison so results when sort_by_popularity is false are 
     187     * comparable to the results of MySQL doing the sorting (as seen most other places 
     188     * in a Symfony app) 
     189     */ 
     190    static public function compareTags($a, $b) 
     191    { 
     192        return strcasecmp($a, $b); 
    183193    } 
    184194