[aklug] Re: MySQL sorting alphanumerics

From: James Zuelow <e5z8652@zuelow.net>
Date: Fri Apr 02 2010 - 21:46:35 AKDT

On Friday 02 April 2010, you wrote:

>
> There's some 'natural' sorting code here
> http://lists.mysql.com/internals/9855
>

Hmm, adding a custom character set for collation would be a little overkill.
Most of the "natural" sorting hits I read earlier referred back to casting as
a number by using +0. Unfortunately that works for 12b but not b12.

> and other places around the web.
>
> If port_name were numeric, it would return in numeric order. Since it's
> text, another approach is to pad with zeros to however many places you
> need.
>
> If ports have both names and numbers, then perhaps two separate fields are
> called for?
>
The interface descriptions come from an SNMP query which returns a string. An
HP-2650 will call its ports 1-50, conveniently using the same numbers as it's
interface id numbers. An HP-4106 will letter the ports according to modules,
then number them within the module: A1 through A20, followed by B1, etc. So
interface 36 on a 4104 might be B16, or it might be C10 if the B module is a
fiber module with only 6 gbic slots. For a human being looking at the front
of the switch, the interface description is much more useful.

However, SNMP can also provide a field for the interface numbers. I could
then retrieve the interface number in the SQL query for sorting purposes but
just not display it to the easily confused human.

Thanks!

James

> jermudgeon
>

---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Fri Apr 2 21:46:48 2010

This archive was generated by hypermail 2.1.8 : Fri Apr 02 2010 - 21:46:48 AKDT