using split for a string : error
rosuav at gmail.com
Fri Jan 25 02:39:18 CET 2013
On Fri, Jan 25, 2013 at 12:33 PM, Oscar Benjamin
<oscar.j.benjamin at gmail.com> wrote:
> I have solved similar situations with
> sorted(filenames, key=lambda s: (len(s), s))
> which is better than lexicographical ordering for sorting integer
> strings. It gets the _Int file wrong in this case (but I consider it
> luck that atoi does what you want for that file).
Yep. Now give me an easy way to rename them all so that the glob *.mid
will produce them in the right order. BTW, there's no guarantee that
the files have no gaps; some other directories have things like
Iol_08_11.mid being followed by Iol_12.mid - I'd rather not renumber
them based on their indices in the final list.
But like I said, it's an unusual case.
More information about the Python-list