[Tutor] Sort

George Nyoro geonyoro at gmail.com
Mon Jan 30 15:32:26 CET 2012


Hey all, again:
Thanks for the delete thing. Helped with that problem a lot. Especially the
getattr thing came in handy.

Question 1:
How do you guys indent and put in the triple greater than signs and all
that when sending mail? Manually? Coz the last mail I sent was using the
gmail indent thing and it doesnt seem to have worked. Anyway:

Question 2:
I have this script that downloaded a lot of files from one server into one
local directory and the files are named in a particular order and I want
them to be opened in this very same order so that I can copy the contents
of each to one main file and then convert to pdf. However, the naming
schema is like this (Roman numerals in parts) and python doesn't seem to be
able to sort it properly.
1.I.1; 1.I.2; ....; 1.I.20;
1.II.1.1;1.II.1.2
1.II.2;...1.II.10; 2.I.3;
Because of the roman numerals that are always in the second part fo the
filename, it could sort based on how I wanted.

I listed all the files in the said directory:
files=os.listdir(location)

I tried using a sort algorithm that goes through the list starting from
index 0 and then compares each index with the next one and if they are not
arranged as they should be, the two are switched and then it starts again.
The thing is, it is so slow! It hardly goes past index three in the list
and there are so many files. *about fifty*.

Could anyone help me with the python impelentation of such an algorith and
how it should sort. Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120130/d1f7b8cf/attachment.html>


More information about the Tutor mailing list