On Thu, Apr 8, 2010 at 3:52 PM, Ben Racine <i3enha...@gmail.com> wrote:
> I have a list...
>
> ['dir_0_error.dat', 'dir_120_error.dat', 'dir_30_error.dat', 
> 'dir_330_error.dat']
>
> I want to sort it based upon the numerical value only.

a = ['dir_0_error.dat', 'dir_120_error.dat', 'dir_30_error.dat',
'dir_330_error.dat']
def key(item):
    return int(item.split('_')[1])
a.sort(key=key)

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to