The Alphanum Algorithm in Python

Path: mv.asterisco.pt!mvalente
From: mvale…@ruido-visual.pt (Mario Valente)
Newsgroups: mv
Subject: The Alphanum Algorithm in Python
Date: Wed, 12 Dec 07 01:12:21 GMT

And, in a heroic session of coding (the last couple of
hours really; yes, it took me that long, goddam regular
expressions…) the geezer comes up with the Python
version of the Alphanum algorithm…

The Alphanum Algorithm
http://www.davekoelle.com/alphanum.html

Alphanum Algorithm in Python
http://mv.asterisco.pt/Files/alphanum.py

Yay for me, I still remember how to code….

— MV

PS – Yes, I later found the solution below but I had fun meanwhile…

def safeint(x):
try:
return int(x)
except ValueError:
return x
data.sort(key=lambda x: map(safeint, re.findall(“\d+|\D+”, x)))

Comments are closed.