Renier Leenders wrote:
Hello,
I think this question is OT but nevertheless. I don't know where to put my question elsewhere. I use Zope as some kind of 'frontend' for an relational database. I want to use the database to store laws. The idea is to retrieve articles with "SELECT FROM law WHERE article_number >= x and article_number <= y". Unfortunately not all law articles are numbered with 1, 2, 3, etc. If they were I could define article_number as integer. But some articles are numbered with 1, 2, 2a ... 13ab etc. When I define the article_number as char and I retrieve I get a result with an sorting order like this: 1,10,11,11a,11b,12, 13ab ... 2a, 20, 21,21a. I could not find a database who supports "natural sort". Has someone an idea to work around this problem with Zope? Any suggestions would be appreciated.
In python, you could transform the strings to lists of strings of length 1, i.e. '12' -> ['1','2']. Now build a list of these lists and sort it. This should work, try it on a python command line. But I don't know if something like this exists in a database. HTH, oliver