Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

wild4life2013

macrumors newbie
Original poster
Mar 13, 2013
14
0
I am looking for a way to sort a list of dates and if there is a date the same then sort by time.

Code:
set a_RandomExampleList to {"Some Event 1/2/2014", "Another Event 2/6/2014", "Some Other Event 1/6/2014", "The Magic show 2/2/2014 14:00", "Band 2/2/2014 13:00"}

thanks for any help
 

larswik

macrumors 68000
Sep 8, 2006
1,552
11
I think your are going to need to post some real code for people to help you out with. If you have no examples of what you done then there is no way to help you resolve the problem.
 

dmi

macrumors regular
Dec 21, 2010
162
33
Code:
set a_RandomExampleList to {"Some Event 1/2/2014", "Another Event 2/6/2014", "Some Other Event 1/6/2014", "The Magic show 2/2/2014 14:00", "Band 2/2/2014 13:00"}
set old_delims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {ASCII character 10}
set list_string to (a_RandomExampleList as string)
set new_string to do shell script "echo " & quoted form of list_string & " | perl -e 'print map/\\0(.*)/s,sort map sprintf(qq(%4d%2d%2d%s\\0%s),(m{(.*?(\\d+)/(\\d+)/(\\d+)(.*))}s)[3,1,2,4,0]),<>'"
set new_list to (paragraphs of new_string)
set AppleScript's text item delimiters to old_delims
return new_list
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.