Listfiles problem with Mojave 10.14

I just upgraded to Mojave 10.14.
I ran a simple procedure that has been working fine since I upgraded to Pan X.
It checks for files in the download folder, which is sorted by date. It processes the list to have the most recent first in the list and then presents it.

    fgArDownloads=""
fgSearch=""
arrayfilter listfiles("~/Downloads",".csv"),fgArDownloads,cr(),?(import() BEGINSWITH "CCSettlement",import(),"")
arraystrip fgArDownloads,cr()
fgArDownloads=arrayreverse(fgArDownloads,cr())

Now however, the frArDownloads variable if presenting the data in some order I haven’t figured out (here’s a small sample)

CCSettlement-08_15(08-59_AM)-2.csv
CCSettlement-06_18(08-38_AM).csv
CCSettlement-05_07(08-41_AM).csv
CCSettlement-07_07(04-09_PM).csv
CCSettlement-10_09(08-49_AM).csv
CCSettlement-11_18(04-32_PM)-2.csv
CCSettlement-12_05(08-39_AM)-2.csv
CCSettlement-06_28(08-33_AM).csv
CCSettlement-04_30(08-33_AM).csv
CCSettlement-10_27(02-18_PM)-2.csv
CCSettlement-06_05(08-50_AM).csv
CCSettlement-11_09(07-52_PM)-2.csv
CCSettlement-12_11(08-52_AM)-2.csv

Any idea what is happening?

IMHO the Finder’s display order does not play any role here.

If you want your array to be sorted, you can add one line of code to your procedure:

arraysort frArDownloads, frArDownloads, chr(13)

That should give you an alphabetically sorted file list.

Thanks, I did add that code after posting and it works.
Still prior to the upgrade it was sorting in the finder order and I’ve been using it daily for almost a year, so curious if it is going to effect anything else.

Martin McCaffery

martinmc@knology.net

You were just lucky. Kurt is right, the Finder order has nothing to do with the order returned by listfiles(. The listfiles( function just returns the files in the order they are returned by macOS, which is not guaranteed to be any particular order at all. It’s quite possible that different versions of macOS could return the files in a different order.