Sort files and display in iOS

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
shoshinsha
Posts: 35
Joined: Fri Jul 18, 2014 5:17 am

Sort files and display in iOS

Post by shoshinsha » Mon Sep 22, 2014 5:43 am

Hi,

I've built an iOS app in which one part is to display list of files saved in the iOS device special folder path "documents".
I need to sort the files by date (newest entry to oldest entry) before displaying them in the field list.

How I sort the files:

Code: Select all

put the detailed files into tmp
sort lines of tmp descending by item 4 of each
It works and the files are sorted nicely on my Mac.
But when the app is transferred to my iPod, the list is not sorted (or more specifically, there are sorted by alphabetical order).

Is it due to the filesystem in mobile is different from desktop/laptop?
Is there any better way to sort files by newest to oldest and be displayed on mobile device?

Appreciate any help and advice!
Thank you.

shoshinsha
Posts: 35
Joined: Fri Jul 18, 2014 5:17 am

Re: Sort files and display in iOS

Post by shoshinsha » Tue Sep 23, 2014 5:01 am

It seems that if I sort by item 5 it works on both mobile and mac.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Sort files and display in iOS

Post by jmburnod » Tue Sep 23, 2014 9:07 am

Hi shoshinsha,
Is it due to the filesystem in mobile is different from desktop/laptop?
The only difference I know is that IOS is casesensitive but an integer is not concerned
It seems that if I sort by item 5 it works on both mobile and mac.
Strange that your script works with item 5 but not with item 4 which is also an integer
Best regards
Jean-Marc
https://alternatic.ch

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4166
Joined: Sun Jan 07, 2007 9:12 pm

Re: Sort files and display in iOS

Post by bn » Tue Sep 23, 2014 10:31 am

Hi shoshinsha,

maybe you should add numeric to your code. Since you are sorting the seconds which is a number it should be numeric.

But it is entirely possible that on iOS item 4 does not work

from the dictionary:
The detailed files form returns a list of files, one file per line. Each line contains the following attributes, separated by commas:
* The file's name, URL-encoded
* The file's size in bytes (on Mac OS and OS X systems, the size of the file's data fork)
* The resource fork size in bytes (Mac OS and OS X systems only)
* The file's creation date in seconds (Mac OS, OS X, and Windows systems only)
* The file's modification date in seconds
etc.
It states that item 4 is (Mac OS, OS X, and Windows systems only), no mention of iOS and Android.

You could test this and put the detailed files into a temporary field on iOS and see what it returns

numeric would be a good idea even on item 5

Kind regards

Bernd

shoshinsha
Posts: 35
Joined: Fri Jul 18, 2014 5:17 am

Re: Sort files and display in iOS

Post by shoshinsha » Tue Sep 23, 2014 10:57 am

Thanks everyone for replying!
I will play around more on this...

Post Reply