There are some subtle and crucial concepts that I meet again and again. The problem is that once I’m done with them sometimes I tend to forget some of them. Sorting string variables in a humane (alphabetical, natural) instead of ASCIIbetical order is just one of those concepts. I had to re-discover this issue as I was trying to write a file renaming program in Python today. My problem can be described as

>>> "u11-Phrase 099.wav" < "u11-Phrase 1000.wav"
True

>>> "u11-Phrase 100.wav" < "u11-Phrase 1000.wav"
True

>>> "u11-Phrase 101.wav" < "u11-Phrase 1000.wav"
False

So according Python (or your favorite language’s default sort functionality!) “u11-Phrase 100.wav” comes before “u11-Phrase 1000.wav” but “u11-Phrase 101.wav” comes after “u11-Phrase 1000.wav”!

For solutions please see one of those:

Benzer Yazılar / Similar Posts:

Tags:

This entry was posted on Monday, December 21st, 2009 at 5:30 pm and is filed under General, Programlama. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

2 comments so far

 1 

Python Cookbook(O’Reilly)’de bundan bahsediliyordu yanlış hatırlamıyorsam, güzel bir kaynak..

December 22nd, 2009 at 7:29 pm
 2 

It’s nice to see you using StackOverflow.

December 25th, 2009 at 11:12 am

Leave a reply

Name (*)
Mail (will not be published) (*)
URI
Comment