Re: using split for a string : error

Discussion in 'Python' started by Chris Angelico, Jan 25, 2013.

  1. On Fri, Jan 25, 2013 at 12:33 PM, Oscar Benjamin
    <> 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.

    ChrisA
    Chris Angelico, Jan 25, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    450
  2. Carlos Ribeiro
    Replies:
    11
    Views:
    684
    Alex Martelli
    Sep 17, 2004
  3. trans.  (T. Onoma)

    split on '' (and another for split -1)

    trans. (T. Onoma), Dec 27, 2004, in forum: Ruby
    Replies:
    10
    Views:
    201
    Florian Gross
    Dec 28, 2004
  4. Sam Kong
    Replies:
    5
    Views:
    223
    Rick DeNatale
    Aug 12, 2006
  5. Stanley Xu
    Replies:
    2
    Views:
    582
    Stanley Xu
    Mar 23, 2011
Loading...

Share This Page