Sorting a list of devices

bw4/exp/mot1
bw4/exp/mot10
bw4/exp/mot11
bw4/exp/mot12
bw4/exp/mot13
...

The following example shows how to sort the list:

import string
import re

def cmpr( x,  y):
    pattern = re.compile( ".+mot(\d+)")
    return cmp( string.atoi( pattern.match( x).group(1)),
                string.atoi( pattern.match( y).group(1)))

self.devices = self.db.get_device_exported( "*exp/mot*")
self.devices.sort( cmpr)