faqts : Computers : Programming : Languages : Python : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

5 of 6 people (83%) answered Yes
Recently 5 of 6 people (83%) answered Yes

Entry

How can I do to list files in a dir sorting for date?

Feb 15th, 2004 10:45
Washington Corrêa, Harley Pax,


Here it goes:
def listDir(p):
  arqs = os.listdir(p)
  arqd = map(lambda x: [os.path.getctime(p + "/" + x), x], arqs)
  arqd.sort()
  return map(lambda x: x[1], arqd)
Example:
g = listDir('/temp')
for i in g:
  print i
ok?
Junior