[Mediawiki-l] How to get article titles sorted by numeric value, not text value?

Frank Middleton f.middleton at apogeect.com
Fri Oct 5 22:54:45 UTC 2007


Jim Laurino wrote:
> On 10/05/2007 03:48:14 PM, Monahon Peter B. - Peter.Monahon at USPTO.GOV wrote:
>>> Earlier: "...[how to] empower MediaWiki 
>>> (code / variables / MySQL?) to show 
>>> articles titles in lists sorted by numeric 
>>> value, not text value...
>>> ...now...(example):
>>> [[1800]]
>>> [[1801.1]]
>>> [[1801]]
>>> [[700]]
>>> ...Rather then the preferred:
>>> [[700]]
>>> [[1800]]
>>> [[1801]]
>>> [[1801.1]] 
>>> ... Is this a MySQL database quirk, or 
>>> something selectable in PHP, even if
>>> requiring an enhancement?..."

Did you look at http://www.mediawiki.org/wiki/Extension:Semantic_MediaWiki?

They extend the Category system by allowing you to add attributes
which are typed, specifically to address this issue, as well as
avoiding the affect of having millions of possible pages. I
have not used it because I found a simpler solution for what I
needed, but it might suit your need.

-- Frank


>> Considering this example at Wikipedia:
>> http://en.wikipedia.org/w/index.php?title=Special:Categories&limit=500
>> ...
>> # 1009 establishments (2 members)
>> # 100 BC (6 members)
>> ...
>> ...I'd presume that no one has addressed the "sort by
>> numeric value, not text value" challenge yet.  Has anyone?  Does anyone
>> have any clue as to where this sorting alternative (numeric versus text)
>> may be addressed?  MySQL or PHP or ...?  Anybody?  Anybody?
> 
> Workers in the hyper-rational U.S. bureaucracy have to breath this stuff,
> the rest of us get to make fun of it from time to time.
> 
> Seriously, this is a common problem, just not in page titles.
> That is, trying to use numerals as text and wanting numeric sorts
> instead of dictionary sorts. But a general solution is hard.
> Part of the problem is that these are only semi-numbers,
> I bet you would be not be surprised to see "712.34.56".
> The usual way I deal with this is to use special knowledge
> of the scheme to expand these strings into a full representation.
> For example, in your scheme, convert 700 to 0700.0, etc.
> Now the titles will sort as you expect. 
> To do this you need to know how many digits are allowed
> on both sides of the decimal point, which is hard to generalize.
> No one is surprised any more by a zip code such as 02139,
> but if the modified title is too strange, you could probably
> find a way to use the modified title only for sorting
> and let users see the titles the way they are used to.
> My guess is that sorting modified title strings
> would work better and be quicker for you to do
> than trying to build-in a special sorting exception.
> 
> Hope that helps,
> 
> Jim
> 
> 
> _______________________________________________
> MediaWiki-l mailing list
> MediaWiki-l at lists.wikimedia.org
> http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
> 



More information about the MediaWiki-l mailing list