Script to select a most recent file in a folder?

Hi! I would like to make a script that select a most recetly modified file in a folder. For example, in a folder called “Movil Agenda” I have various copies of my Movil Agenda. With this script a select a Movil Agenda file most recently modified.
Thanks!
Alex

you could just sort by modification date

but this will do the trick

(*
this code was descended from Apple sample
code, but that i've made changes.
*)

try
	tell application "Finder" to set the source_folder to POSIX path of (folder of the front window as alias)
on error -- no open folder windows
	set the source_folder to POSIX path of (path to desktop folder as alias)
end try

set ls to do shell script "cd " & source_folder & "
ls -tl"

set lsl to textToList(ls, return)

set thoneL to textToList(item 2 of lsl, " ")
set newL to {}
repeat with i from 1 to number of items in thoneL
	set this_item to item i of thoneL
	if this_item is not " " then set end of newL to this_item
end repeat
set news to ""
repeat with i from 9 to number of items in newL
	set this_item to item i of newL
	if news is "" then
		set news to this_item
	else
		set news to news & " " & this_item
	end if
end repeat
tell application "Finder" to set selection to POSIX file (source_folder & news)



on textToList(theText, theSep)
	set soFar to {}
	set textSoFar to theText
	repeat until theSep is not in textSoFar
		set thePos to the offset of theSep in textSoFar
		set thenewPos to thePos
		if thenewPos is 1 then set thenewPos to 2
		set nextBit to text 1 through (thenewPos - 1) of textSoFar
		if textSoFar is not theSep then
			set textSoFar to text (thePos + (count of text items in theSep)) through -1 of textSoFar
			copy nextBit to the end of soFar
		else
			set textSoFar to ""
		end if
	end repeat
	copy textSoFar to the end of soFar
	return soFar
end textToList


Tiger:

set theFolder to choose folder
tell app "Finder"
	select item -1 of (sort (get files of folder theFolder) by modification date))
end

Pre-Tiger:

set theFolder to choose folder
tell application "Finder"
	set fileRefs to files of folder fold
	set modDates to modification date of files of folder theFolder
end tell
set fileRef to fileRefs's item 1
set modDate to modDates's item 1
repeat with i from 2 to fileRefs's length
	if modDates's item i > modDate then
		set fileRef to fileRefs's item i
		set modDate to modDates's item i
	end if
end repeat
tell application "Finder" to select fileRef

Cool Scripts! Thank you! It works perfectly! Where did you learn so much? I would like to be like you!
Thanks again!
Alex