Ad Widget

Collapse

Suggestion: Sort lists with strnatcasecmp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ekenberg
    Junior Member
    • Mar 2006
    • 21

    #1

    Suggestion: Sort lists with strnatcasecmp

    Long lists of hosts with numerical parts sort (according to SQL "ORDER BY") in this counter-intuitive way:
    Code:
    host1
    host11
    host12
    host2
    host21
    host3
    A few hundred lines sorted in this manner is annoying to say the least.

    I suggest sorting lines with something like strnatcasecmp() (http://php.net/manual/en/function.strnatcasecmp.php) to make navigation in long lists more consistent.

    AFAIK there is no equivalent of strnatcmp() in MySQL 5 (?) so it would probably have to be done in PHP after retreiving the data. On the other hand, ORDER BY could be removed from the SQL query.

    /Johan
Working...