Sorting files by created time

Hi all,
I have a script that I am using to pull specific type of files from a folder. These are Time coded video files. I would like the script to pull the files chronologically so that each clip is added subsequently in the timeline. However, it seems to be pulling by file size or something. Could anyone please help me change this? Thank you so much.



set theCount to 1
set theFolder to choose folder with prompt "Choose folder with Audio files you want to join together."
tell application "Finder"
	set theFiles to files of folder theFolder whose name ends with ".mp4"
	set totalFiles to (count the theFiles)
	repeat with i from 1 to totalFiles --to 1 by -1
		set thisfile to item i of theFiles as alias
		
		--QT Pro
		my mergeFilesUsingQT(thisfile, theCount, totalFiles)
		
		set theCount to theCount + 1
	end repeat
	
end tell

on mergeFilesUsingQT(thisfile, theCount, totalFiles)
	tell application "QuickTime Player 7"
		set show welcome movie automatically to false
		activate
		--the first file only gets copied
		if theCount = 1 then
			open thisfile
			delay 0.5
			tell document 1
				select all
				copy
			end tell
			close document 1 saving no
			
		else
			--these files get the previous file added to it and
			--then it is copied to be added to the next file
			open thisfile
			delay 1
			tell document 1
				set x to get duration
				set current time to x
				paste
				select all
				copy
			end tell
			
			if theCount = totalFiles then
			else
				close document 1 saving no
			end if
		end if
	end tell
end mergeFilesUsingQT

--Closing and saving the document
tell application "QuickTime Player 7"
	set filename to (path to desktop folder as string) & "test.mov"
	save document 1 in filename
	quit
end tell


Hi,

this line sorts the files by creation date, oldest first.
If you want newest first, remove reverse of


.
set theFiles to reverse of (sort (files of folder theFolder whose name ends with ".mp4") by creation date)
.

Thank you, I am going to check this out. You rock!