Natural sorting

So far street names that start or end in a number were sorted in simple textual order, e.g. 1-10-11-…-19-2-20-21-…

Now, with the help of the Python “natsort” package, these will be listed in “natural” order, like 1-2-…-10-11-…-19-20-21-…

At first this only worked for ASCII / Latin numbers, but with two little fixes to the “natsort” package it should now work for all numeric unicode characters (tested with Persian/Farsi so far).

3 thoughts on “Natural sorting”

  1. It turned out that there are still some edge cases that are not well covered, e.g. I just found a plan with this street order:

    79th Street
    80th Avenue West
    80th Street
    8½th Avenue
    8½th Street
    8½th Street Court
    8½th Street West
    81st Avenue West
    82nd Avenue West

    8½th should actually be between 8th and 9th, not 80th and 81st. So my proposed natsort changes are not perfect yet, but probably a big improvement already nonetheless …

Leave a Reply to hartmut Cancel reply

Your email address will not be published. Required fields are marked *