See Python Unicode Collation Algorithm for background. This version fixes a major bug that prevented the collation algorithm from working properly with any expansions:
http://jtauber.com/2006/02/13/pyuca.py
UPDATE (2012-06-21): Now see https://github.com/jtauber/pyuca