Re: [Tutor] sort list alphabetically

2005-11-24 Thread lmac
Ok. That's the point. I think i meant case-sensitive. There are some ways described here that will me help out. Yes, the list is sorted when i print it out. It was my fault, sorry guys. Thank you a lot. mac ___ Tutor maillist - Tutor@python.org http:/

Re: [Tutor] sort list alphabetically

2005-11-23 Thread Danny Yoo
> In python2.4, you can also use the key= keyword argument: > > ### > def toUpper(s): > return s.upper() > files.sort(key=toUpper) > ### > > This is more efficient, I believe, because the key function is only > called once for each element, whereas cmp is called more than once. > > (we could use

Re: [Tutor] sort list alphabetically

2005-11-23 Thread John Fouhy
On 24/11/05, Danny Yoo <[EMAIL PROTECTED]> wrote: > The files that start with uppercase come first because of the way those > strings compare to lowercase strings. If we want a case-insensitive sort, > we can do something like this: > > ## > >>> def case_insensitive_cmp(a, b): > ... return

Re: [Tutor] sort list alphabetically

2005-11-23 Thread bob
At 09:55 AM 11/23/2005, lmac wrote: >i have a list with the dirs/files from the current path. When i use >sort() to sort the list alphabetically the list is still unsorted. When you say "unsorted" - are the list members in the same order as before the sort? >dirs_files = os.listdir(os.getcwd())

Re: [Tutor] sort list alphabetically

2005-11-23 Thread Danny Yoo
On Wed, 23 Nov 2005, lmac wrote: > i have a list with the dirs/files from the current path. When i use > sort() to sort the list alphabetically the list is still unsorted. How > to use ? > > dirs_files = os.listdir(os.getcwd()) > print dirs_files > dirs_files.sort() > print dirs_files Hi lmac,

[Tutor] sort list alphabetically

2005-11-23 Thread lmac
Hallo, i have a list with the dirs/files from the current path. When i use sort() to sort the list alphabetically the list is still unsorted. How to use ? dirs_files = os.listdir(os.getcwd()) print dirs_files dirs_files.sort() print dirs_files Thank you. _