Fwd: data grid, custom sorting
Sarah Reichelt
sarah.reichelt at gmail.com
Sat May 2 19:16:45 EDT 2009
On Sun, May 3, 2009 at 6:37 AM, Shao Sean <shaosean at wehostmacs.com> wrote:
> I have raw file sizes in bytes (as is customary) but am displaying it
> formatted (KB, MB, etc) but the sorting of the column is obviously not
> sorted correctly. Is there a way to sort on the actual data in the dgData so
> the it sorts correctly? Or failing that, if I hide a column with the raw
> file sizes and trap the header sorting, is there a way to sort on the "size"
> column but have the header selected on the "sizeFormatted" column?
Sounds like time for one of Jacque's brilliant custom sort functions,
assuming you can do that with a datagrid.
I think it would be something like this, but I'm sure Jacque will
correct me if I have it wrong:
sort lines of fld "Whatever" by sizeSort(item 3 of each)
function sizeSort pSize
if word 2 of pSize = "KB" then
return pSize * 1024
else if word 2 of pSize = "MB" then
return pSize * 1024 * 1024
else
return pSize
end if
end sizeSort
Cheers,
Sarah
More information about the use-livecode
mailing list